amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

scrollTo() does not work while page is scrolling

Open aghassemi opened this issue 7 years ago • 4 comments

If scrollTo() is called while page is scrolling (e.g. continuation of a momentum scroll), it does nothing.

Not a big deal but somewhat annoying. related: #16860

aghassemi avatar Aug 10 '18 22:08 aghassemi

From what I can tell, this is not a problem for desktop browsers. I tested manually on macOS on Chrome, Opera, Firefox, and Safari and experienced that scrollTo worked even while momentum scrolling was active.

I did experience the problem using Chrome on both Android and iOS devices, and I believe the underlaying cause is the following. When scrollTo is assigned to the tap event, i.e. on="element-id.scrollTo(), the tap event is not registered while inertial scrolling is occurring. From the point of view of the mobile operating systems, this is working as intended. When inertial scrolling, a user tap is not intentionally interacting with the webpage but rather to stop the inertial scrolling. An unintended side effect of stopping inertial scrolling with a tap would be to click on an underlaying web element and be navigated to a different page, or in our case, to be scrolled to the top.

Knowing this, is this still something we want to change? A common way to solve this is to set a small timeout when calling scrollTo, but I'm not sure what support we have to do that.

caroqliu avatar Mar 29 '19 21:03 caroqliu

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 30 '21 03:01 stale[bot]

@ampproject/wg-components Anyone interested in investigating?

caroqliu avatar Feb 01 '21 15:02 caroqliu

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 30 '22 18:07 stale[bot]