svelte-intersection-observer
Advanced tools
Comparing version 0.9.2 to 0.10.0
@@ -8,2 +8,16 @@ # Changelog | ||
## [0.10.0](https://github.com/metonym/svelte-intersection-observer/releases/tag/v0.10.0) - 2021-12-29 | ||
**Features** | ||
- mark `observer` for garbage collection after disconnecting | ||
**Documentation** | ||
- make prop descriptions consistent with docs | ||
**Refactoring** | ||
- omit redundant `null` from `element` and `root` types as `HTMLElement` is already nullable | ||
## [0.9.2](https://github.com/metonym/svelte-intersection-observer/releases/tag/v0.9.2) - 2021-11-26 | ||
@@ -10,0 +24,0 @@ |
@@ -340,4 +340,4 @@ (function (global, factory) { | ||
const get_default_slot_changes = dirty => ({ | ||
intersecting: dirty & /*intersecting*/ 2, | ||
entry: dirty & /*entry*/ 1, | ||
intersecting: dirty & /*intersecting*/ 1, | ||
entry: dirty & /*entry*/ 2, | ||
observer: dirty & /*observer*/ 4 | ||
@@ -347,4 +347,4 @@ }); | ||
const get_default_slot_context = ctx => ({ | ||
intersecting: /*intersecting*/ ctx[1], | ||
entry: /*entry*/ ctx[0], | ||
intersecting: /*intersecting*/ ctx[0], | ||
entry: /*entry*/ ctx[1], | ||
observer: /*observer*/ ctx[2] | ||
@@ -404,2 +404,3 @@ }); | ||
let { once = false } = $$props; | ||
let { intersecting = false } = $$props; | ||
let { root = null } = $$props; | ||
@@ -409,3 +410,2 @@ let { rootMargin = "0px" } = $$props; | ||
let { entry = null } = $$props; | ||
let { intersecting = false } = $$props; | ||
let { observer = null } = $$props; | ||
@@ -419,4 +419,4 @@ const dispatch = createEventDispatcher(); | ||
entries.forEach(_entry => { | ||
$$invalidate(0, entry = _entry); | ||
$$invalidate(1, intersecting = _entry.isIntersecting); | ||
$$invalidate(1, entry = _entry); | ||
$$invalidate(0, intersecting = _entry.isIntersecting); | ||
}); | ||
@@ -431,3 +431,6 @@ }, | ||
return () => { | ||
if (observer) observer.disconnect(); | ||
if (observer) { | ||
observer.disconnect(); | ||
$$invalidate(2, observer = null); | ||
} | ||
}; | ||
@@ -466,7 +469,7 @@ }); | ||
if ('once' in $$props) $$invalidate(4, once = $$props.once); | ||
if ('intersecting' in $$props) $$invalidate(0, intersecting = $$props.intersecting); | ||
if ('root' in $$props) $$invalidate(5, root = $$props.root); | ||
if ('rootMargin' in $$props) $$invalidate(6, rootMargin = $$props.rootMargin); | ||
if ('threshold' in $$props) $$invalidate(7, threshold = $$props.threshold); | ||
if ('entry' in $$props) $$invalidate(0, entry = $$props.entry); | ||
if ('intersecting' in $$props) $$invalidate(1, intersecting = $$props.intersecting); | ||
if ('entry' in $$props) $$invalidate(1, entry = $$props.entry); | ||
if ('observer' in $$props) $$invalidate(2, observer = $$props.observer); | ||
@@ -477,4 +480,4 @@ if ('$$scope' in $$props) $$invalidate(8, $$scope = $$props.$$scope); | ||
return [ | ||
intersecting, | ||
entry, | ||
intersecting, | ||
observer, | ||
@@ -498,7 +501,7 @@ element, | ||
once: 4, | ||
intersecting: 0, | ||
root: 5, | ||
rootMargin: 6, | ||
threshold: 7, | ||
entry: 0, | ||
intersecting: 1, | ||
entry: 1, | ||
observer: 2 | ||
@@ -505,0 +508,0 @@ }); |
{ | ||
"name": "svelte-intersection-observer", | ||
"version": "0.9.2", | ||
"version": "0.10.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Detect if an element is in the viewport using the Intersection Observer API", |
@@ -164,3 +164,3 @@ # svelte-intersection-observer | ||
Note that all properties in `IntersectionObserverEntry` are read only. | ||
Note that all properties in `IntersectionObserverEntry` are read-only. | ||
@@ -167,0 +167,0 @@ <details> |
@@ -8,12 +8,30 @@ /// <reference types="svelte" /> | ||
/** | ||
* The HTML Element to observe. | ||
* @default null | ||
*/ | ||
element?: null | HTMLElement; | ||
element?: HTMLElement; | ||
/** | ||
* Set to `true` to unobserve the element | ||
* after it intersects the viewport. | ||
* @default false | ||
*/ | ||
once?: boolean; | ||
/** | ||
* `true` if the observed element | ||
* is intersecting the viewport. | ||
* @default false | ||
*/ | ||
intersecting?: boolean; | ||
/** | ||
* Specify the containing element. | ||
* Defaults to the browser viewport. | ||
* @default null | ||
*/ | ||
root?: null | HTMLElement; | ||
root?: HTMLElement; | ||
/** | ||
* Margin offset of the containing element. | ||
* @default "0px" | ||
@@ -24,2 +42,4 @@ */ | ||
/** | ||
* Percentage of element visibility to trigger an event. | ||
* Value must be between 0 and 1. | ||
* @default 0 | ||
@@ -30,2 +50,3 @@ */ | ||
/** | ||
* Observed element metadata. | ||
* @default null | ||
@@ -36,15 +57,6 @@ */ | ||
/** | ||
* @default false | ||
*/ | ||
intersecting?: boolean; | ||
/** | ||
* `IntersectionObserver` instance. | ||
* @default null | ||
*/ | ||
observer?: null | IntersectionObserver; | ||
/** | ||
* @default false | ||
*/ | ||
once?: boolean; | ||
} | ||
@@ -51,0 +63,0 @@ |
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
48384
1030