-
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
Add baseline infrastructure for animations in amp-story #11525
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the design overview. Feel free to address minor comments in a follow-up.
*/ | ||
|
||
/** @typedef {!Array<!Object<string, *>>} */ | ||
export let Keyframes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suffix typedefs with "Def", i.e. KeyFramesDef
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
constructor( | ||
page, animationDef, webAnimationBuilderPromise, vsync, timer, sequence) { | ||
/** @private @const */ | ||
this.page_ = page; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Types for these ivars?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are they needed here? Since they're @const
and directly assigned from a typed param, Closure could then do inference, right?
import {setStyle, resetStyles} from '../../../src/style'; | ||
|
||
|
||
const ANIMATE_IN_ATTRIBUTE_NAME = 'animate-in'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @const {string} */
IIRC, Closure is pretty dumb about this so we have to do some handholding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
/** | ||
* @param {!PlaybackActivity} activity | ||
* @param {!Promise=} opt_wait |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@private
IIRC, Closure needs this annotation for obfuscation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oversight on my part, thanks.
/** | ||
* Executes playback activity if runner is ready. | ||
* @param {!PlaybackActivity} activity | ||
* @param {?Promise} wait |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
*/ | ||
notifyFinish(id) { | ||
if (id in this.subscriptionPromises_) { | ||
dev().assert(this.subscriptionResolvers_)[id](); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean dev().assert(this.subscriptionResolvers_[id])()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup!
} | ||
|
||
/** | ||
* @param {string} name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@param {!Element} el
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops
*/ | ||
createAnimationBuilderPromise_() { | ||
return Services.extensionsFor(this.ampdoc_.win) | ||
.loadExtension('amp-animation') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want installExtensionForDoc
here which will de-dupe loads. loadExtension
was renamed preloadExtension
during a refactor for better AmpDoc support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks.
|
||
// TODO(alanorozco): Looping animations | ||
/** Manager for animations in story pages. */ | ||
export class AnimationManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: This file is large enough to split into two IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will follow-up
|
||
|
||
/** Bus for animation sequencing. */ | ||
class AnimationSequence { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signals.js
does something pretty similar FYI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's cool. I'll look into whether the bus can be replaced with this.
General design aspects
amp-animation
format (i.e. more restrictions)animate-in
attribute. Other animation properties are configured with the attributesanimate-in-duration
,animate-in-delay
andanimate-in-after
.animation-presets.js
defines the preset animations that can be used in stories.AnimationRunner
handles the entrance animation defined for a given element.AnimationManager
handles the entrance animations for a given story page.AnimationSequence
is a bus shared by allAnimationRunner
s for sequencing.