svelte-intersection-observer
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -8,5 +8,5 @@ # Changelog | ||
## Unreleased | ||
## [0.1.1](https://github.com/metonym/svelte-intersection-observer/releases/tag/v0.1.1) - 2020-04-05 | ||
- Allow a `disconnectOnly` option to preserve the Intersection Observer instance | ||
- Only `disconnect` observer in `onDestroy` lifecycle method | ||
@@ -13,0 +13,0 @@ ## [0.1.0](https://github.com/metonym/svelte-intersection-observer/releases/tag/v0.1.0) - 2020-04-05 |
@@ -357,6 +357,6 @@ (function (global, factory) { | ||
function instance($$self, $$props, $$invalidate) { | ||
let { element = null } = $$props; // HTMLElement | ||
let { root = null } = $$props; // HTMLElement | ||
let { rootMargin = "0px" } = $$props; | ||
let { threshold = 0 } = $$props; | ||
let { element = null } = $$props; // HTMLElement | ||
const dispatch = createEventDispatcher(); | ||
@@ -386,4 +386,3 @@ let entry = null; | ||
onDestroy(() => { | ||
observer.disconnect(); // TODO: enable 'disconnectOnly' option? | ||
observer = undefined; | ||
observer.disconnect(); | ||
}); | ||
@@ -394,6 +393,6 @@ | ||
$$self.$set = $$props => { | ||
if ("root" in $$props) $$invalidate(2, root = $$props.root); | ||
if ("rootMargin" in $$props) $$invalidate(3, rootMargin = $$props.rootMargin); | ||
if ("threshold" in $$props) $$invalidate(4, threshold = $$props.threshold); | ||
if ("element" in $$props) $$invalidate(5, element = $$props.element); | ||
if ("element" in $$props) $$invalidate(2, element = $$props.element); | ||
if ("root" in $$props) $$invalidate(3, root = $$props.root); | ||
if ("rootMargin" in $$props) $$invalidate(4, rootMargin = $$props.rootMargin); | ||
if ("threshold" in $$props) $$invalidate(5, threshold = $$props.threshold); | ||
if ("$$scope" in $$props) $$invalidate(8, $$scope = $$props.$$scope); | ||
@@ -403,12 +402,10 @@ }; | ||
$$self.$$.update = () => { | ||
if ($$self.$$.dirty & /*root, rootMargin, threshold*/ 28) { | ||
{ | ||
observer = new IntersectionObserver(entries => { | ||
entries.forEach(_entry => { | ||
$$invalidate(0, entry = _entry); | ||
$$invalidate(1, intersecting = _entry.isIntersecting); | ||
}); | ||
}, | ||
{ root, rootMargin, threshold }); | ||
} | ||
if ($$self.$$.dirty & /*root, rootMargin, threshold*/ 56) { | ||
observer = new IntersectionObserver(entries => { | ||
entries.forEach(_entry => { | ||
$$invalidate(0, entry = _entry); | ||
$$invalidate(1, intersecting = _entry.isIntersecting); | ||
}); | ||
}, | ||
{ root, rootMargin, threshold }); | ||
} | ||
@@ -420,6 +417,6 @@ }; | ||
intersecting, | ||
element, | ||
root, | ||
rootMargin, | ||
threshold, | ||
element, | ||
prevElement, | ||
@@ -437,6 +434,6 @@ dispatch, | ||
init(this, options, instance, create_fragment, safe_not_equal, { | ||
root: 2, | ||
rootMargin: 3, | ||
threshold: 4, | ||
element: 5 | ||
element: 2, | ||
root: 3, | ||
rootMargin: 4, | ||
threshold: 5 | ||
}); | ||
@@ -443,0 +440,0 @@ } |
{ | ||
"name": "svelte-intersection-observer", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Detect if an element is in the viewport using the Intersection Observer API", |
@@ -38,10 +38,10 @@ # svelte-intersection-observer | ||
| ------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | | ||
| element | Element observed for intersecting changes | `HTMLElement` | | ||
| element | Element observed for intersection | `HTMLElement` | | ||
| root | Containing element | `null` or `HTMLElement` (default: `null`) | | ||
| rootMargin | Offset of the containing element | `string` (default: `"0px"`) | | ||
| threshold | Percentage of the intersecting element to be visible to trigger an intersection event | `number` between 0 and 1 (default: `0`) | | ||
| threshold | Percentage of element to trigger an event | `number` between 0 and 1 (default: `0`) | | ||
| intersecting | If the element is intersecting | `boolean` | | ||
| entry | Observed element metadata triggered when intersecting | `null` or [`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) | | ||
| entry | Observed element metadata | `null` or [`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) | | ||
### Dispatched Event | ||
### Dispatched Events | ||
@@ -48,0 +48,0 @@ The `observe` event is dispatched when an intersection change occurs. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33370
824