Adding wide elements to page causes scroll jump
Reported by
teo8...@gmail.com,
Jul 1 2016
|
|||||||
Issue descriptionExample URL: http://output.jsbin.com/bejepud Steps to reproduce the problem: 1. on Android, visit http://output.jsbin.com/bejepud 2. Scroll to the bottom 3. Click the "Test" button What is the expected behavior? The document may become larger than the viewport, and hence horizontally scrollable, because a "visibility:hidden" element has been added near the top of the page. However, until you try to scroll horizontally, you should notice nothing. What went wrong? When you click the button, the page scrolls up to the position where the invisible div has been created Does it occur on multiple sites: Yes Is it a problem with a plugin? No Did this work before? N/A Does this work in other browsers? N/A Chrome version: 51.0.2704.106 Channel: stable OS Version: Flash Version: Shockwave Flash 22.0 r0 I understand that automatic scrolling to the position where new content is created may be a usability feature for mobiles. However: - a way MUST be provided to prevent this behavior, otherwise it's totally unacceptable - it is very questionable that this is the default behavior when the viewport meta tag is set to "width=device-width, initial-scale=1". (after all, you don't scroll to newly created content on desktop, do you? so why on mobile?) - it is CERTAINLY WRONG to do so when the created content is invisible.
,
Jul 1 2016
Just found out: this only happens if the created element exceeds the viewport width. So, this is clearly not a usability feature, it's just a bug. To recap: - if you add content that is outside the viewport above the top or below the bottom, but it does not exceed the viewport width, the window doesn't scroll automatically to the newly created content's position - if the created content exceeds the width, then it does If the rationale behind this is that content that is added to the document is likely to be intended to be viewed by the user and if it is outside the screen this is likely to be unintended (which is already a too dangerous assumption), it doesn't make any sense to change the behavior depending on whether or not the content exceeds the viewport width.
,
Jul 7 2016
,
Jul 7 2016
This seems to already be fixed in Canary, I don't see the scroll jump there. teo8976@, could you confirm? There is still an issue that we reset the zoom level when a wide element gets added (try making the added element 2000px wide instead) since we try to zoom out to fit the whole page. I'd guess that's also the logic that previously caused the scroll jump but something changed recently. We probably shouldn't do that after the page finishes loading, but there's always edge cases. You can work around this by specifying a minimum-zoom in your viewport <meta> tag or by putting all your content in a container with `overflow-x: hidden` to prevent the content becoming wider than your viewport. This is related to issue 438588 and more generally issue 437303 Given that this is "mostly" working and there's workarounds, I don't think this is high priority and I don't currently have the cycles to get to it any time soon.
,
Jul 7 2016
> There is still an issue that we reset the zoom level when a wide element > gets added (try making the added element 2000px wide instead) What do you mean by "wide"? Are you saying that there is an absolute threshold other than the width of the device screen? That there is a difference between adding a 1000px wide element and adding a 2000px wide element even if both are wider than the device screen? If that is the case, that's certainly a nonsense behavior. When the page has the meta tag <meta content="width=device-width, initial-scale=1"> you should never, ever zoom out automatically no matter what. Well actually I have just tested, changing the width in my example and I don't see any zoom out, fortunately. But I am testing the stable version, not Canary, which I don't even know how to get. > This seems to already be fixed in Canary, I don't see the scroll jump there. > teo8976@, could you confirm? Does Canary for Android even exist?? I went to https://www.google.es/chrome/browser/canary.html (which is the first result on google for "chrome canary") with my Android phone, and it tells me: "Chrome Canary is currently not available on the linux platform. You can try Chrome Canary for Windows 32-bit, Windows 64-bit or OSX." By the way, unrelated suggestion: at https://www.google.es/chrome/browser/canary.html one of the first things I'd expect to find is an explanation of what Canary is in the first place.
,
Jul 7 2016
Sorry, right, on Android you can get get Chrome Dev channel which is a little behind what Canary would be but very close to bleeding edge. Unfortunately, it seems to still be broken there so the fixing change must be quite recent. > Are you saying that there is an absolute threshold other than the width of the device screen? > That there is a difference between adding a 1000px wide element and adding a 2000px wide element > even if both are wider than the device screen? I'm saying that during loading, if you have an element that's wider than the screen size (like setting an explicit with on a div), we'll load the page zoomed out so that the full width of the content can be seen. The difference between 1000px and 2000px is that the wider div will cause us to zoom out further. >When the page has the meta tag > <meta content="width=device-width, initial-scale=1"> > you should never, ever zoom out automatically no matter what. Agreed, and I don't think we do normally. Actually, on second inspection, I didn't notice the page had a meta tag at all. It seems that what I was seeing is that the viewport tag was not getting applied at all. I'll take a look after all as there seems to be something fishy going on.
,
Jul 7 2016
> I'm saying that during loading, if you have an element > that's wider than the screen size (like setting an explicit > with on a div), we'll load the page zoomed out so that the > full width of the content can be seen. Oh, ok, that is without the viewport meta tag, which I see you had missed.
,
Jul 11 2016
Ok, I took a deeper look and there is indeed a bug which I'll fix shortly. The problem is that inserting a wide element like this grows the layout viewport. The reason we do this is the size of the layout viewport determines how far you can zoom out. We want to be able to encompass all the content horizontally when we zoom out fully so we make the layout viewport the same width as the content. When we grow the layout viewport horizontally like this, we also expand vertically to keep the same aspect ratio. The issue here is that we're already fully scrolled. When we make the layout viewport's height bigger, it means the maximum scroll position shrinks so that's why the scroll jumps. The correct thing to do here would be to anchor the scroll so that the visual viewport remains in the same location. You can work around this for now by explicitly setting a minimum-scale in your viewport meta tag. Having an explicit minimum-scale means that we won't make the layout viewport any larger than needed for this scale, even if you have wider content.
,
Sep 24 2016
I think you changed the title of the issue when you hadn't realized we were talking about the case when there is a viewport metatag. I'd suggest to change it back, as it is quite confusing now. There's no zooming out involved, the issue is an unexpected scroll jump.
,
Sep 25 2016
,
Nov 7 2016
,
Apr 6 2017
,
May 16 2017
Can not reproduce this issue on 58.0.3029.83 Android.
,
Jun 5 2017
Confirmed, see attached test case for adding wide element when scrolled at bottom. I suspect scroll anchoring may have helped here. |
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by teo8...@gmail.com
, Jul 1 2016