Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Chrome's scroll preserving feature

I have a page containing a list of items:

enter image description here

Load more button should load some more items via ajax and append it to the items container preserving current scroll position. So after I click it the feed I expect it to look like this (green items are new):

enter image description here

But in fact Chrome 56 executes some computations to make the page stay in the same state, and what I see looks like this:

enter image description here

Is there any way to prevent this smart scrolling position setting in Chrome?

Update: I can reproduce the behavior only if parent container ('body' in my case) has 'display: flex' property (I use it to achieve 'sticky footer' feature).

like image 266
everyonesdesign Avatar asked Feb 13 '17 13:02

everyonesdesign


People also ask

How do I turn off scroll anchoring?

What if I need to disable it? The specification provides a new property, overflow-anchor , which can be used to disable scroll anchoring on all or part of the document. It's essentially a way to opt out of the new behavior.

How do I turn on scroll anchoring in chrome?

Go to chrome://flags/#enable-scroll-anchoring on Chrome Dev / Canary. Select “Enabled” from the dropdown. Click “Relaunch Now” at the bottom of the screen.

How do I disable scroll behavior in CSS?

Disabling scroll with only CSS There's another way to disable scrolling that is commonly used when opening modals or scrollable floating elements. And it is simply by adding the CSS property overflow: hidden; on the element you want to prevent the scroll.


1 Answers

I solved a similar problem by adding overflow-anchor: none; to the scroll container.

https://wicg.github.io/ScrollAnchoring/

like image 165
Marko Avatar answered Nov 18 '22 11:11

Marko