-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scroll-bound amp-animation #8411
Comments
@dvoytenko So the original design was fairly close to what we discussed today. (it is a bit more powerful as it allows different ratios for end/start optionally). It however does not allow margin offsets for the scene container, given container itself can be anything, I don't really see he need to allow margins on the scene container anyway. I am planning to implement this design very soon, PTAL |
I'd like to suggest also adding support for binding animation progress to video playback time. This would make it possible to create an HTML layer on top of video (interactive elements, annotations, ...) and have it always be in sync with the playing content. |
@lexandera That's a really neat idea! It fits nicely with the discussions we have been having on #8971 as well. I will combine #8971 and this request into a new feature request for |
Summary
amp-animation
to be ticked using scroll rather than time.amp-animation
to be based onvisibility
of a whole parent container or another element on the page.Sample
Idea
amp-animation
is a wrapper for Web Animation API which allows manual control of the animation timeline usingcurrentTime
property (also supported by the pollyfill). Therefore, scrollboundamp-animation
can be achieved by pausing the animation (anim.pause()
) and then tickinganim.currentTime
withonscroll
. (prototype: http://codepen.io/aghassemi/pen/MpGaGm)duration
property of the animation definition.duration
= amount of scrolling that takes us from start to end based on visibility criteria we talk about.iteration
can still be used, but can’t be infinity. (we divide scroll amount by # of iterations)API
ticker
propertyTicker property can be set on any animation definition:
ticker=<"time"|"scroll">
:Visibility Criteria
One can tie start/end of an
amp-animation
to be based onvisibility
of a whole parent container or another element on the page. This applied to both scroll and time based animations.trigger="scene-visibility"
Specifies that animation's start/end is tied to visibility of the scene.
scene-id=id
Specifies the HTML id of the container element that constructs the scene. The visibility criteria to decide when to start/end the animation will be based on visibility of this elements.
scene-start-visibility-threshold=<fromTop%, fromBottom%>
Indicates at what % of visibility of the scene the animation should start.
Different values could be provided for when scene is entering the viewport from the top vs from the bottom (e.g. using scrolling up or down).
If a single value is provided, it will applied to both fromTop and fromBottom.
Defaults to
0%, 0%
meaning animation will starts as soon as a single pixel of the scene becomes visible.Examples:
%0
(or0%, 0%
)%100
(or100%,100%
)0%,100%
100%,0%
%50
(or50%,50%
)scene-end-visibility-threshold=<fromTop%, fromBottom%>
Indicates at what % of visibility of the scene the animation should end. Otherwise same as
scene-start-threshold
scene-visibility-exclusion-margins=<top, bottom>
Can be used to create exclusion margins on top/bottom of the viewport restricting where
scene-*-threshold
calculation boundaries.Values can be pixel or viewport sizing (
vh
).If a single value is provided, it will applied to both top and bottom
Defaults to
0, 0
meaning thresholds will be calculated based on top/bottom of viewport without any clipping.Examples:
0
(or0
,0
)100
0vh,70vh
33vh,33vh
Questions and Other Considerations
The text was updated successfully, but these errors were encountered: