amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Add support for viewers scrolling away UI during document consumption

Open ericfs opened this issue 10 years ago • 13 comments

E.g. a viewer might show the origin of the doc and may want to hide that as the user scrolls down, but show it again when they scroll up.

Event should be send on scroll event and contain scrollTop and potentially the cached scrollHeight

ericfs avatar May 24 '16 23:05 ericfs

@ericfs Tuned your description a bit :)

Assigned to @muxin

cramforce avatar May 25 '16 00:05 cramforce

The converse of this would enable "tap scrollbar to scroll to top" in iOS. If a user does, it'll trigger a scroll event (if the viewer is not already at the top) in the viewer window. If we send down that scroll event, we can scroll to the top of the AMP doc as well.

jridgewell avatar May 25 '16 18:05 jridgewell

Putting in Backlog for now. @muxin, if you plan to work on soon, please change to Current or Next as appropriate. Thanks!

rudygalfi avatar May 25 '16 23:05 rudygalfi

Thanks for taking this. It looks like only scrollTop is sent and not scrollHeight. Is it possible to get the height too?

ericfs avatar Jul 12 '16 16:07 ericfs

Hmm, when @muxin and I looked at this, it seemed we sent this already, but now I can't find it. We certainly can.

@dvoytenko ScrollHeight is currently not cached. Could we start only recalculating it when we mutated the doc or the viewport changed?

cramforce avatar Jul 12 '16 17:07 cramforce

@cramforce We used to do it and I asked it to be removed (/cc @jridgewell) due to some problems in the way we implemented it. We can bring this back if it's really necessary, but we need to see how. We used to do it in each runtime pass and that was fairly expensive. I think, a better option might be to do it for scroll events specifically, but only calculate scrollHeight once for scroll series.

dvoytenko avatar Jul 12 '16 17:07 dvoytenko

scrollHeight would be helpful, if it's available, particularly to know when the scroll reaches the bottom, but I think we can manage without it.

ericfs avatar Jul 12 '16 17:07 ericfs

@ericfs but what would be the most applicable target message for this info? scroll message?

dvoytenko avatar Jul 12 '16 17:07 dvoytenko

Yes, that would be fine.

ericfs avatar Jul 12 '16 17:07 ericfs

Re: https://github.com/ampproject/amphtml/issues/3515. If we do reintroduce it, we need to cache.

jridgewell avatar Jul 12 '16 17:07 jridgewell

Can we update scroll height:

  • after we build an element
  • after resize
  • after mutate

Are there other situations where it might change?

cramforce avatar Jul 12 '16 17:07 cramforce

@ericfs Do you need a precise value?

cramforce avatar Jul 12 '16 17:07 cramforce

I think it would be preferable, but I think I can work with whatever you can provide. Ideally a Viewer would know when the page is scrolled to the bottom, but an estimate may be ok.

ericfs avatar Jul 12 '16 17:07 ericfs