+ All Categories
Home > Technology > The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

Date post: 14-Apr-2017
Category:
Upload: badoo
View: 440 times
Download: 0 times
Share this document with a friend
30
The Magic of the Infinite Scroller Konstantin Dzuin 16th of August, 2016 London CSS Meetup
Transcript
Page 1: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

The Magic of the Infinite Scroller

Konstantin Dzuin16th of August, 2016 London CSS Meetup

Page 2: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

Hi, I am…

Konstantin Dzuin

Mobile Web developer (html/css) Badoo, London, UK

html/css developer since 2002Badooer since 2013

Twitter: @kdzuin

Page 3: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

3 CSS

developers

7 JS

developers

5 QA

engineers

Mobile Web Team

Page 4: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

People NearbyWe have different ways in which we visualise users. People Nearby is a section

in our application where we display users you have bumped into, or just people nearby according to your location.

Page 5: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

The Contact ListA list of all the connections made both existing and new chats, and matches.

Page 6: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

Visitors, Favourites and more…

Page 7: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

The Challenge

Over 320 million usersThe great number of users that are affected by our solutions. How to display all these users in a single long list?

Smooth UXSupporting Android 2.3+, iPhone and Windows phone devices.

Preserve the StateNavigating through the application (page-page-back)Rotating the device

Page 8: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

Solutions on the MarketCurrently there are a lot of solutions to this on the market but none of them suited our needs. We wanted a balance between maintainability and the-best-technical-idea-ever!

Page 10: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

• Re-use DOM elements

• Layout is built by JavaScript

• Scrolling is native / Scrolling is controlled by JavaScript

The Technique

Page 11: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

CSS: Google

.element

position: absolute; transform: translateY() transition: transform

all the elements are reused and repositioned using translation

.sentinel

position: absolute; transform: translateY() transition: transform

sentinel pixel is translated to the bottom + ‘page’ height to create new scrolling space for new elements

.runway should be empty and all inner elements moved to GPU processing

Page 12: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

CSS: iScroll

.element

position: absolute; transform: translateY() transition: transform

all the elements are reused and repositioned using translation

.canvas

position: absolute; transform: translateY() transition: transform

• the whole canvas is translated • smooth and configurable perception

Page 13: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

All good but complicated

+ 60 fps, Really smooth UX

+ Configurable scrolling perception (iScroll)

– Layout is built by JS, responsibility to maintain the relationships is on JS side

– Difficult to scale and re-use

Page 14: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

Nothing But the Browser

Page 15: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

• No re-use of DOM elements

• Layout is built by CSS

• Scrolling is native

The Technique

Page 16: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

Simple but limited…

+ Layout is build by CSS

– Low performance

– Browser will eventually crash

Page 17: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

Our Solution

Page 18: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

The Technique

• Do not re-use DOM elements

• Hide elements outside the viewport

• Do trust the browser with scroll and layout

Page 19: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

So, how do we hide the elements?

Page 20: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

displaynone

visibilityhidden

Page 21: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

Options

display: none

two extra blocks with calculated

heights before and after the content

calculation of box models before hiding, excluding them from rendering

visibility: hidden

blocks are still in the flow and occupy

their height

calculation of box models,keeping them rendered without effects

Page 22: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

Who wins?

display: none

two extra blocks with calculated heights before and after the content

calculation of box models before hiding, excluding them from rendering

visibility: hidden

blocks are still in the flow and occupy their height

calculation of box models,keeping them rendered without effects

Page 23: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

Who wins?

• No significant difference in performance

• No need to create and calculate extra elements somewhere

• Even works on slow devices

display: none

two extra blocks with calculated

heights before and after the content

calculation of box models before hiding, excluding them from rendering

visibility: hidden

blocks are still in the flow and occupy

their height

calculation of box models,keeping them rendered without effects

Page 24: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

Let Us Compare

Page 26: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

Let’s change the design…

People Nearby

Page 27: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

The Web and Mobile Web are grown up

We can trust the browser

We need to help the browser a bit

The less we reinvent under the browser’s hood – the easier the process of maintenance for the whole system

Just imagine that…

Page 28: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

Questions?

Page 29: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

Thank you!

Page 30: The Magic of the Infinite Scroller - Konstantin Dzuin - London CSS Meetup 2016

https://twitter.com/BadooTech

https://github.com/badoo

https://techblog.badoo.com/

https://twitter.com/kdzuin

http://kdzuin.ru/demos/infinite-scroller/

demo videos


Recommended