-
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
Added percentageVisible{Max,Min} conditions for visibilitySpec. #2881
Conversation
// TODO(avimehta, #1297): Add all the listeners so that visibility | ||
// conditions are monitored and callback is called when the conditions | ||
// are met. | ||
if (!config['visibilitySpec']) { |
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.
Mind flipping the conditionals? !else
double-negatives make everything confusing.
ptal. I am planning to add a few more tests but other stuff is ready for review. |
let VisibilityListenerCallbackDef; | ||
|
||
/** | ||
* @typedef {Object.<string, JSONObject|VisibilityListenerCallbackDef>} |
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.
This always seems to be a VisibilityListenerDef
.
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.
Config is a json object. I add it to the object at https://github.com/ampproject/amphtml/pull/2881/files#diff-6936d113e81d9bf7788ab8e145841720R88
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.
The |
is the confusing part then. Can you create a VisibilityListenerConfigDef
?
|
||
this.registerForViewportEvents_(); | ||
|
||
this.listeners_[resId()] = (this.listeners_[resId()] || []); |
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.
This'll error, resId
isn't a function.
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.
Weird. I swear I ran the tests. will fix.
LGTM. |
Part of #1297
Tests to follow.