I have a page containing a list of items:
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):
But in fact Chrome 56 executes some computations to make the page stay in the same state, and what I see looks like this:
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).
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.
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.
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.
I solved a similar problem by adding overflow-anchor: none;
to the scroll container.
https://wicg.github.io/ScrollAnchoring/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With