Skip to content
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

InOb polyfill trigger new added element w/o tick #8100

Merged
merged 4 commits into from
Mar 14, 2017

Conversation

zhouyx
Copy link
Contributor

@zhouyx zhouyx commented Mar 13, 2017

fix #7992

  • Always store the last tick viewport position, and use it to calculate change entry to new added element w/o tick
  • If last tick viewport position is not available, do nothing.
  • IntersectionObserverPolyfill creator is responsible for the very first tick during initialization.

@zhouyx zhouyx requested review from dvoytenko and lannka March 13, 2017 21:26
@ampprojectbot
Copy link
Member

Hi, ampproject bot here! Here are a list of the owners that can approve your files.

/to @donttrustthisbot

  • extensions/amp-analytics/0.1/visibility-impl.js
  • src/intersection-observer-polyfill.js
  • test/functional/test-intersection-observer-polyfill.js

this.lastViewportRect_ = null;

/** @private {./layout-rect.LayoutRectDef|undefined} */
this.opt_lastIframeRect_ = undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instance/class vars cannot have opt_ prefix. Please remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@dvoytenko
Copy link
Contributor

LGTM with one request.

@@ -227,11 +234,22 @@ export class IntersectionObserverPolyfill {
}
}

// push new observed element
this.observeEntries_.push({
const newEntry = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed, please avoid overloading the name entry here. Can be called state instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@zhouyx zhouyx merged commit db3107f into ampproject:master Mar 14, 2017
@zhouyx zhouyx deleted the inob-last-tick branch March 14, 2017 00:24
@@ -300,6 +300,7 @@ export class Visibility {
onIntersectionChanges, {threshold: DEFAULT_THRESHOLD});
//TODO: eventually this is go into the proposed layoutManager.
const viewport = viewportForDoc(this.ampdoc);
this.intersectionObserver_.tick(viewport.getRect());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: call ticker instead of duplicating its code.

mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
* store last tick value

* fix type check

* remove opt-

* rename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InOb polyfill: should trigger automatically for new elements w/o ticks
5 participants