New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 699302 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

MD Settings: Experiment replacing paper-header-panel with CSS only solution

Project Member Reported by dpa...@chromium.org, Mar 7 2017

Issue description

paper-header-panel adds a scroll listener to determine when to show/hide the shadow near the top of the panel, see [1]. Scroll listeners are expensive and can make the page feel less responsive than it can be (see timeline attachments).

There seem to exist equivalent CSS only solutions to achieve the same effect, using background-image and background-attachment, see [2]. It is probably worth experimenting with removing paper-header-panel in favor of a CSS only solution in MD Settings.

[1] https://cs.chromium.org/chromium/src/third_party/polymer/v1_0/components-chromium/paper-header-panel/paper-header-panel-extracted.js?l=188,216-225,229-230
[2] http://codepen.io/tinystride/pen/bcEJv
 
scroll_handlers_timeline.png
113 KB View Download
no_scroll_handlers_timeline.png
20.7 KB View Download
Cc: dbeam@chromium.org
Description: Show this description

Comment 3 by dbeam@chromium.org, Mar 13 2017

Cc: ffu@chromium.org
Labels: Hotlist-MD-Settings-Structure
Status: Available (was: Untriaged)

Comment 4 by dpa...@chromium.org, Mar 21 2017

Owner: dpa...@chromium.org
Status: Started (was: Available)
I am experimenting with this.

Comment 5 by dpa...@chromium.org, Mar 21 2017

So the experiment can be seen at https://codereview.chromium.org/2184863002.

Visual fidelity
I managed to get it very close, but it is not exact. There is one main difference (see attachments), where in the CSS only solution, because we are using background-image to implement the shadow effect, the white cards are appearing on top of the shadow.

Perceived speed
Scrolling very quickly on my workstation does feel "lighter" with the CSS only solution. Looking at the JS profile during scrolling, there is no JS running at all during scrolling, compared to lot of JS scroll handlers in the paper-header-panel solution (see attachments).

Size reduction
Other than that, we also get some small size savings.
vulcanized.html: 379032 -> 376648,  0.6% reduction in size
crisper.js:      400031 -> 397273,  0.6% reduction in size
css_only_top_bottom_shadow.png
15.1 KB View Download
paper_header_panel.png
23.5 KB View Download
js_profiler_css_only.png
23.3 KB View Download
js_profiler_paper_header_panel.png
149 KB View Download
I wonder if we could do something tricky with a box-shadow on #container::before or cr-toolbar::after, so it appears over the cards.

Comment 7 by dpa...@chromium.org, Mar 21 2017

I made a simplified example that resembles settings layout at https://jsfiddle.net/uy143dsL/3/. Feel free to experiment further. Some of my quick attempts to add an overlay div that holds the background-image have not been successful.
Is that bottom shadow intentional? (it shows up in the actual patch, too)

Comment 9 by dpa...@chromium.org, Mar 21 2017

Yes, I left it there, even though paper-header-panel only had it in the top. It can be easily removed.
Here's a version using box-shadow with :after. https://jsfiddle.net/uy143dsL/4/

Problem is the transition is ugly -- when the scroll position is between [1,11]pixels you see artifacts.

Alternatively CSS scroll snap points might've helped if they were ready... https://www.chromestatus.com/feature/5721832506261504
Transition can be improved by adding gradient to :before element and making it 3x size of :after https://jsfiddle.net/uy143dsL/8/
Cc: esprehn@chromium.org
Followed the suggestion by esprehn@ and experimented with IntersertionObserver. I think this is very promising (100% visual fidelity to paper-header-panel), and instead of 'scroll' event handlers we get a notification as necessary (scrolled to top, not scrolled to top).

See it live at https://jsfiddle.net/zjL8709b/2/.
Status: Fixed (was: Started)
CL landed, https://codereview.chromium.org/2184863002.

Sign in to add a comment