intersection-observer-admin
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -19,3 +19,3 @@ "use strict"; | ||
*/ | ||
add(element, enterCallback, exitCallback, observerOptions, scrollableArea) { | ||
observe(element, enterCallback, exitCallback, observerOptions, scrollableArea) { | ||
if (!element || !observerOptions) { | ||
@@ -157,3 +157,5 @@ return; | ||
_findRoot(root) { | ||
return this.DOMRef && this.DOMRef.get(root); | ||
if (this.DOMRef) { | ||
return this.DOMRef.get(root); | ||
} | ||
} | ||
@@ -160,0 +162,0 @@ /** |
@@ -27,3 +27,3 @@ function unwrapExports (x) { | ||
*/ | ||
add(element, enterCallback, exitCallback, observerOptions, scrollableArea) { | ||
observe(element, enterCallback, exitCallback, observerOptions, scrollableArea) { | ||
if (!element || !observerOptions) { | ||
@@ -165,3 +165,5 @@ return; | ||
_findRoot(root) { | ||
return this.DOMRef && this.DOMRef.get(root); | ||
if (this.DOMRef) { | ||
return this.DOMRef.get(root); | ||
} | ||
} | ||
@@ -168,0 +170,0 @@ /** |
@@ -33,3 +33,3 @@ (function (global, factory) { | ||
*/ | ||
add(element, enterCallback, exitCallback, observerOptions, scrollableArea) { | ||
observe(element, enterCallback, exitCallback, observerOptions, scrollableArea) { | ||
if (!element || !observerOptions) { | ||
@@ -171,3 +171,5 @@ return; | ||
_findRoot(root) { | ||
return this.DOMRef && this.DOMRef.get(root); | ||
if (this.DOMRef) { | ||
return this.DOMRef.get(root); | ||
} | ||
} | ||
@@ -174,0 +176,0 @@ /** |
@@ -35,3 +35,3 @@ declare type IndividualEntry = { | ||
*/ | ||
add(element: HTMLElement, enterCallback: Function, exitCallback: Function, observerOptions?: IObserverOption, scrollableArea?: string): void; | ||
observe(element: HTMLElement, enterCallback: Function, exitCallback: Function, observerOptions?: IObserverOption, scrollableArea?: string): void; | ||
/** | ||
@@ -38,0 +38,0 @@ * Unobserve target element and remove element from static admin |
{ | ||
"name": "intersection-observer-admin", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Intersection Observer Admin for better performance", | ||
@@ -5,0 +5,0 @@ "main": "dist/intersection-observer-admin.umd.js", |
@@ -9,6 +9,8 @@ intersection-observer-admin | ||
Why use this? | ||
Why use an administrator to manage all the elements on my page? | ||
------------------------------------------------------------------------------ | ||
This library is used in [ember-in-viewport](https://github.com/DockYard/ember-in-viewport). This library is particularly important for re-using the IntersectionObserver API. [IntersectionObserver.observer](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/observe) can observer multiple elements. So this library will resuse the IntersectionObserver instance for another element on the page with the same set of observer options and root element. This can dramatically improve performance for pages with lots of elements and observers. | ||
This library is used in [ember-in-viewport](https://github.com/DockYard/ember-in-viewport). This library is particularly important for re-using the IntersectionObserver API. | ||
Most implementations have one Intersection Observer for each target element or so called `sentinel`. However, [IntersectionObserver.observe](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/observe) can observer multiple `sentinels`. So this library will resuse the IntersectionObserver instance for another element on the page with the same set of observer options and root element. This can dramatically improve performance for pages with lots of elements and observers. | ||
Installation | ||
@@ -41,3 +43,3 @@ ------------------------------------------------------------------------------ | ||
// add an element to static administrator | ||
intersectionObserverAdmin.add(element, enterCallback, exitCallback, { root, rootMargin: '0px 0px 100px 0px', threshold: 0 }); | ||
intersectionObserverAdmin.observe(element, enterCallback, exitCallback, { root, rootMargin: '0px 0px 100px 0px', threshold: 0 }); | ||
@@ -44,0 +46,0 @@ // remove an element from the static administrator |
Sorry, the diff of this file is not supported yet
46255
903
100