@onsvisual/svelte-components 1.0.43 → 1.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,11 @@
8
8
  * @type {boolean}
9
9
  */
10
10
  export let visible = false;
11
+ /**
12
+ * Number of pixels before/after the viewport that component is considered "visible" (default = 0).
13
+ * @type {number}
14
+ */
15
+ export let rootMargin = 0;
11
16
 
12
17
  let el, observer;
13
18
 
@@ -21,7 +26,7 @@
21
26
  };
22
27
 
23
28
  onMount(() => {
24
- let options = {};
29
+ let options = { root: document, rootMargin: `${rootMargin}px` };
25
30
 
26
31
  observer = new IntersectionObserver(callback, options);
27
32
  observer.observe(el);
@@ -2,6 +2,7 @@
2
2
  /** @typedef {typeof __propDef.events} ObserveEvents */
3
3
  /** @typedef {typeof __propDef.slots} ObserveSlots */
4
4
  export default class Observe extends SvelteComponentTyped<{
5
+ rootMargin?: number | undefined;
5
6
  visible?: boolean | undefined;
6
7
  }, {
7
8
  enter: CustomEvent<any>;
@@ -18,6 +19,7 @@ export type ObserveSlots = typeof __propDef.slots;
18
19
  import { SvelteComponentTyped } from "svelte";
19
20
  declare const __propDef: {
20
21
  props: {
22
+ rootMargin?: number | undefined;
21
23
  visible?: boolean | undefined;
22
24
  };
23
25
  events: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "npm run build:package && npm run build:docs",