svelte-intersection-observer
Advanced tools
Comparing version 0.7.1 to 0.8.0
@@ -8,2 +8,6 @@ # Changelog | ||
## [0.8.0](https://github.com/metonym/svelte-intersection-observer/releases/tag/v0.8.0) - 2021-09-02 | ||
- use `.svelte.d.ts` extension for component TypeScript definition | ||
## [0.7.1](https://github.com/metonym/svelte-intersection-observer/releases/tag/v0.7.1) - 2021-07-05 | ||
@@ -10,0 +14,0 @@ |
@@ -61,4 +61,3 @@ (function (global, factory) { | ||
} | ||
function update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) { | ||
const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn); | ||
function update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) { | ||
if (slot_changes) { | ||
@@ -69,2 +68,13 @@ const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn); | ||
} | ||
function get_all_dirty_from_scope($$scope) { | ||
if ($$scope.ctx.length > 32) { | ||
const dirty = []; | ||
const length = $$scope.ctx.length / 32; | ||
for (let i = 0; i < length; i++) { | ||
dirty[i] = -1; | ||
} | ||
return dirty; | ||
} | ||
return -1; | ||
} | ||
function detach(node) { | ||
@@ -76,5 +86,5 @@ node.parentNode.removeChild(node); | ||
} | ||
function custom_event(type, detail) { | ||
function custom_event(type, detail, bubbles = false) { | ||
const e = document.createEvent('CustomEvent'); | ||
e.initCustomEvent(type, false, false, detail); | ||
e.initCustomEvent(type, bubbles, false, detail); | ||
return e; | ||
@@ -243,3 +253,3 @@ } | ||
} | ||
function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) { | ||
function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) { | ||
const parent_component = current_component; | ||
@@ -265,4 +275,6 @@ set_current_component(component); | ||
dirty, | ||
skip_bound: false | ||
skip_bound: false, | ||
root: options.target || parent_component.$$.root | ||
}; | ||
append_styles && append_styles($$.root); | ||
let ready = false; | ||
@@ -330,3 +342,3 @@ $$.ctx = instance | ||
/* src/IntersectionObserver.svelte generated by Svelte v3.38.3 */ | ||
/* src/IntersectionObserver.svelte generated by Svelte v3.42.4 */ | ||
@@ -364,3 +376,12 @@ const get_default_slot_changes = dirty => ({ | ||
if (default_slot.p && (!current || dirty & /*$$scope, intersecting, entry, observer*/ 263)) { | ||
update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[8], !current ? -1 : dirty, get_default_slot_changes, get_default_slot_context); | ||
update_slot_base( | ||
default_slot, | ||
default_slot_template, | ||
ctx, | ||
/*$$scope*/ ctx[8], | ||
!current | ||
? get_all_dirty_from_scope(/*$$scope*/ ctx[8]) | ||
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[8], dirty, get_default_slot_changes), | ||
get_default_slot_context | ||
); | ||
} | ||
@@ -444,11 +465,11 @@ } | ||
$$self.$$set = $$props => { | ||
if ("element" in $$props) $$invalidate(3, element = $$props.element); | ||
if ("once" in $$props) $$invalidate(4, once = $$props.once); | ||
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 ("observer" in $$props) $$invalidate(2, observer = $$props.observer); | ||
if ("$$scope" in $$props) $$invalidate(8, $$scope = $$props.$$scope); | ||
if ('element' in $$props) $$invalidate(3, element = $$props.element); | ||
if ('once' in $$props) $$invalidate(4, once = $$props.once); | ||
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 ('observer' in $$props) $$invalidate(2, observer = $$props.observer); | ||
if ('$$scope' in $$props) $$invalidate(8, $$scope = $$props.$$scope); | ||
}; | ||
@@ -455,0 +476,0 @@ |
{ | ||
"name": "svelte-intersection-observer", | ||
"version": "0.7.1", | ||
"version": "0.8.0", | ||
"license": "MIT", | ||
@@ -14,6 +14,5 @@ "description": "Detect if an element is in the viewport using the Intersection Observer API", | ||
"dev": "rollup -cw", | ||
"predeploy": "rollup -c", | ||
"deploy": "npx gh-pages -d dist", | ||
"build": "rollup -c", | ||
"prepack": "BUNDLE=true rollup -c", | ||
"test": "svelte-check --workspace=test", | ||
"test": "svelte-check --workspace test", | ||
"format": "prettier --write '.'" | ||
@@ -23,6 +22,6 @@ }, | ||
"prettier": "^2.3.2", | ||
"prettier-plugin-svelte": "^2.3.1", | ||
"svelte": "^3.38.3", | ||
"svelte-check": "^2.2.0", | ||
"svelte-readme": "^3.1.0" | ||
"prettier-plugin-svelte": "^2.4.0", | ||
"svelte": "^3.42.4", | ||
"svelte-check": "^2.2.5", | ||
"svelte-readme": "^3.3.1" | ||
}, | ||
@@ -29,0 +28,0 @@ "repository": { |
@@ -91,3 +91,3 @@ # svelte-intersection-observer | ||
**Compared to `on:observe`, this event is dispatched only when the element is _intersecting the viewport_.** | ||
**Note**: Compared to `on:observe`, `on:intersect` is dispatched only when the element is _intersecting the viewport_. In other words, `e.detail.isIntersecting` will only be `true`. | ||
@@ -99,2 +99,3 @@ ```html | ||
console.log(e.detail); // IntersectionObserverEntry | ||
console.log(e.detail.isIntersecting); // true | ||
}}" | ||
@@ -110,12 +111,12 @@ > | ||
| Name | Description | Value | | ||
| :----------- | :---------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------- | | ||
| element | Element observed for intersection | `HTMLElement` | | ||
| once | If `true`, the observed element will be unobserved upon intersect | `boolean` (default: `false`) | | ||
| intersecting | `true` if the observed element is intersecting the viewport | `boolean` (default: `false`) | | ||
| root | Containing element | `null` or `HTMLElement` (default: `null`) | | ||
| rootMargin | Margin offset of the containing element | `string` (default: `"0px"`) | | ||
| threshold | Percentage of element visibility to trigger an event | `number` between 0 and 1 (default: `0`) | | ||
| entry | Observed element metadata | [`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) | | ||
| observer | IntersectionObserver instance | [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver) | | ||
| Name | Description | Type | Default value | | ||
| :----------- | :------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------- | :------------ | | ||
| element | Element observed for intersection | `HTMLElement` | `null` | | ||
| once | If `true`, the observed element will be unobserved upon intersection | `boolean` | `false` | | ||
| intersecting | `true` if the observed element is intersecting the viewport | `boolean` | `false` | | ||
| root | Containing element | `null` or `HTMLElement` | `null` | | ||
| rootMargin | Margin offset of the containing element | `string` | `"0px"` | | ||
| threshold | Percentage of element visibility to trigger an event | `number` between 0 and 1 | `0` | | ||
| entry | Observed element metadata | [`IntersectionObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry) | `null` | | ||
| observer | IntersectionObserver instance | [`IntersectionObserver`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver) | `null` | | ||
@@ -134,4 +135,3 @@ ### Dispatched events | ||
<!-- prettier-ignore-start --> | ||
```js | ||
```ts | ||
interface IntersectionObserverEntry { | ||
@@ -175,3 +175,2 @@ target: HTMLElement; | ||
``` | ||
<!-- prettier-ignore-end --> | ||
@@ -178,0 +177,0 @@ </details> |
@@ -1,1 +0,1 @@ | ||
export { default as default } from "./IntersectionObserver"; | ||
export { default as default } from "./IntersectionObserver.svelte"; |
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
45522
999
201