-
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
Simplify scroll tracking and greatly increase frequency of viewability events #1163
Conversation
this.scrollTop_ = newScrollTop; | ||
this.scrollMeasureTime_ = timer.now(); | ||
timer.delay(() => this.scrollDeferred_(), 500); | ||
this.vsync_.measure(() => { |
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.
Is vsync for throttling of for sync? Normally, when scroll event arrives, the value is already calculated by the browser and no sync needed. That, of course, mightn't always work with some of the bindings we have.
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.
Good point. Moved out of vsync.
Actually, if you only measure and do not mutate, it is always fine to do that in an event handler. In the worst case it trigger recalc but it would make the next vsync cheaper since we start with the measure phase.
918aa71
to
05ebec2
Compare
PTAL |
/** | ||
* This method is called about every 3 frames (assuming 60hz) and it | ||
* is called in a vsync measure task. | ||
* @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.
Add @param
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
LGTM with one comment to fix jsdoc with |
emit viewport change events on scroll. - The scroll event now always fires in vsync and always measures scrollTop. - The viewport change event now happens at the latest 3 frames after scrolling ended. - Increased speed at which we send change event. Needed due to resolution at slow speed, but I also feel the value is better. Changes ad intersection to fire "on scroll". Fixes ampproject#873 Fixes a bug where only the first viewability provider in an ad would get an initial viewability change record. Fixes ampproject#1126
05ebec2
to
3543226
Compare
Simplify scroll tracking and greatly increase frequency of viewability events
scrollTop.
scrolling ended.
Changes ad intersection to fire "on scroll". Fixes #873
Fixes a bug where only the first viewability provider in an ad would get an initial viewability change record. Fixes #1126