Skip to content

Add a polyfill for IntersectionObserver#135

Merged
szager-chromium merged 53 commits intow3c:gh-pagesfrom
philipwalton:polyfill
Jul 14, 2016
Merged

Add a polyfill for IntersectionObserver#135
szager-chromium merged 53 commits intow3c:gh-pagesfrom
philipwalton:polyfill

Conversation

@philipwalton
Copy link
Copy Markdown
Member

This script builds on top of the original work done in #121 with the following changes:

  • Adds support for the rootMargin property
  • Adds logic to account for parent elements with non-visible overflow
  • Adds support for elements on a delayed intersection (e.g. CSS transitions)
  • Adds detection of elements on the boundary
  • Adds detection of zero-sized elements within root's bounds
  • Updates to support targets and roots being added/removed from the DOM
  • Removes newer ES6 constructs (like Map) for broader support

With these changes, this polyfill test suite passes in native implementations (Chrome 52+), the latest version of all major browsers, and IE back to version 8 (I didn't test 6-7, but they may work as well).

TODO:

This version uses polling on a 100ms timeout to get the greatest legacy support. I plan to add new logic to use a combination of scroll, resize, and MutationObserver listeners + temporary polling to detect CSS transitions soon, but I wanted to start the pull request with my initial set of changes so we could discuss.

/cc @surma @ojanvafai @triblondon

Loading
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.

8 participants