svelte-legos
Advanced tools
Comparing version 0.0.4 to 0.0.5
{ | ||
"name": "svelte-legos", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"main": "./package/index.js", | ||
@@ -59,3 +59,6 @@ "repository": { | ||
"types": "./package/index.d.ts", | ||
"svelte": "./package/index.js" | ||
"svelte": "./package/index.js", | ||
"import": "./package/index.js", | ||
"require": "./package/index.js" | ||
} | ||
@@ -62,0 +65,0 @@ }, |
@@ -21,2 +21,4 @@ export { counterStore } from "./stores/counterStore"; | ||
export { readableStore } from "./stores/readableStore"; | ||
export { networkStore } from "./stores/networkStore"; | ||
export { onlineStore } from "./stores/onlineStore"; | ||
export { clickOutsideAction } from "./actions/clickOutsideAction"; | ||
@@ -35,1 +37,3 @@ export { longPressAction } from "./actions/longPressAction"; | ||
export { alertAction } from "./actions/alertAction"; | ||
export { clickToCopyAction } from "./actions/clickToCopyAction"; | ||
export { lazyLoadImageAction } from "./actions/lazyLoadImageAction"; |
@@ -21,2 +21,4 @@ export { counterStore } from "./stores/counterStore"; | ||
export { readableStore } from "./stores/readableStore"; | ||
export { networkStore } from "./stores/networkStore"; | ||
export { onlineStore } from "./stores/onlineStore"; | ||
@@ -35,2 +37,4 @@ export { clickOutsideAction } from './actions/clickOutsideAction'; | ||
export { messageAction } from './actions/messageAction'; | ||
export { alertAction } from './actions/alertAction'; | ||
export { alertAction } from './actions/alertAction'; | ||
export { clickToCopyAction } from './actions/clickToCopyAction'; | ||
export { lazyLoadImageAction } from './actions/lazyLoadImageAction'; |
{ | ||
"name": "svelte-legos", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "./package/index.js", | ||
@@ -47,3 +47,5 @@ "repository": { | ||
"types": "./package/index.d.ts", | ||
"svelte": "./package/index.js" | ||
"svelte": "./package/index.js", | ||
"import": "./package/index.js", | ||
"require": "./package/index.js" | ||
}, | ||
@@ -60,2 +62,7 @@ "./.DS_Store": "./.DS_Store", | ||
"./actions/clickOutsideAction/usage.txt": "./actions/clickOutsideAction/usage.txt", | ||
"./actions/clickToCopyAction/Clipboard": "./actions/clickToCopyAction/Clipboard.js", | ||
"./actions/clickToCopyAction/demo.svelte": "./actions/clickToCopyAction/demo.svelte", | ||
"./actions/clickToCopyAction": "./actions/clickToCopyAction/index.js", | ||
"./actions/clickToCopyAction/meta.json": "./actions/clickToCopyAction/meta.json", | ||
"./actions/clickToCopyAction/usage.txt": "./actions/clickToCopyAction/usage.txt", | ||
"./actions/draggableAction/demo.svelte": "./actions/draggableAction/demo.svelte", | ||
@@ -69,2 +76,6 @@ "./actions/draggableAction": "./actions/draggableAction/index.js", | ||
"./actions/hoverAction/usage.txt": "./actions/hoverAction/usage.txt", | ||
"./actions/lazyLoadImageAction/demo.svelte": "./actions/lazyLoadImageAction/demo.svelte", | ||
"./actions/lazyLoadImageAction": "./actions/lazyLoadImageAction/index.js", | ||
"./actions/lazyLoadImageAction/meta.json": "./actions/lazyLoadImageAction/meta.json", | ||
"./actions/lazyLoadImageAction/usage.txt": "./actions/lazyLoadImageAction/usage.txt", | ||
"./actions/loadingAction/Loader": "./actions/loadingAction/Loader.js", | ||
@@ -163,2 +174,10 @@ "./actions/loadingAction/demo.svelte": "./actions/loadingAction/demo.svelte", | ||
"./stores/mouseStore/usage.txt": "./stores/mouseStore/usage.txt", | ||
"./stores/networkStore/demo.svelte": "./stores/networkStore/demo.svelte", | ||
"./stores/networkStore": "./stores/networkStore/index.js", | ||
"./stores/networkStore/meta.json": "./stores/networkStore/meta.json", | ||
"./stores/networkStore/usage.txt": "./stores/networkStore/usage.txt", | ||
"./stores/onlineStore/demo.svelte": "./stores/onlineStore/demo.svelte", | ||
"./stores/onlineStore": "./stores/onlineStore/index.js", | ||
"./stores/onlineStore/meta.json": "./stores/onlineStore/meta.json", | ||
"./stores/onlineStore/usage.txt": "./stores/onlineStore/usage.txt", | ||
"./stores/rafFnStore/demo.svelte": "./stores/rafFnStore/demo.svelte", | ||
@@ -165,0 +184,0 @@ "./stores/rafFnStore": "./stores/rafFnStore/index.js", |
@@ -56,3 +56,3 @@ import { SvelteComponentTyped } from "svelte"; | ||
unselectable?: "on" | "off" | null | undefined; | ||
inputmode?: "text" | "search" | "numeric" | "none" | "tel" | "url" | "email" | "decimal" | null | undefined; | ||
inputmode?: "none" | "text" | "search" | "numeric" | "tel" | "url" | "email" | "decimal" | null | undefined; | ||
is?: string | null | undefined; | ||
@@ -78,3 +78,3 @@ 'bind:innerHTML'?: string | null | undefined; | ||
'aria-disabled'?: import("svelte/elements").Booleanish | null | undefined; | ||
'aria-dropeffect'?: "copy" | "link" | "move" | "none" | "execute" | "popup" | null | undefined; | ||
'aria-dropeffect'?: "copy" | "none" | "link" | "move" | "execute" | "popup" | null | undefined; | ||
'aria-errormessage'?: string | null | undefined; | ||
@@ -109,3 +109,3 @@ 'aria-expanded'?: import("svelte/elements").Booleanish | null | undefined; | ||
'aria-setsize'?: number | null | undefined; | ||
'aria-sort'?: "none" | "ascending" | "descending" | "other" | null | undefined; | ||
'aria-sort'?: "none" | "other" | "ascending" | "descending" | null | undefined; | ||
'aria-valuemax'?: number | null | undefined; | ||
@@ -112,0 +112,0 @@ 'aria-valuemin'?: number | null | undefined; |
import type { ConfigurableWindow } from "../../shared/utils/types"; | ||
import { type Readable } from "svelte/store"; | ||
export declare function elementVisibilityStore(target: Element | null, { window }?: ConfigurableWindow): Readable<boolean>; | ||
export declare function elementVisibilityStore(target: Element | null, { window }?: ConfigurableWindow): { | ||
isVisible: Readable<boolean>; | ||
stop: () => void; | ||
}; |
@@ -5,25 +5,28 @@ import { defaultWindow, tryOnDestroy, writableToReadable } from "../../shared"; | ||
const store = writable(false); | ||
if (target !== null) { | ||
function check() { | ||
if (!window) | ||
return; | ||
if (target === null) | ||
return; | ||
const document = window.document; | ||
const rect = target.getBoundingClientRect(); | ||
const test = (rect.top <= | ||
(window.innerHeight || document.documentElement.clientHeight) && | ||
rect.left <= | ||
(window.innerWidth || document.documentElement.clientWidth) && | ||
rect.bottom >= 0 && | ||
rect.right >= 0); | ||
store.set(test); | ||
} | ||
function stop() { | ||
window?.removeEventListener('scroll', check); | ||
} | ||
function check() { | ||
if (!window) | ||
return; | ||
if (target === null) | ||
return; | ||
const document = window.document; | ||
const rect = target.getBoundingClientRect(); | ||
const test = (rect.top <= | ||
(window.innerHeight || document.documentElement.clientHeight) && | ||
rect.left <= | ||
(window.innerWidth || document.documentElement.clientWidth) && | ||
rect.bottom >= 0 && | ||
rect.right >= 0); | ||
store.set(test); | ||
} | ||
function start() { | ||
stop(); | ||
window?.addEventListener('scroll', check, { capture: false, passive: true }); | ||
check(); | ||
tryOnDestroy(() => { | ||
window?.removeEventListener('scroll', check); | ||
}); | ||
} | ||
return writableToReadable(store); | ||
start(); | ||
tryOnDestroy(stop); | ||
return { isVisible: writableToReadable(store), stop }; | ||
} |
@@ -6,5 +6,5 @@ <script lang="ts"> | ||
$: isVisible = elementVisibilityStore(ref); | ||
$: ({ isVisible } = elementVisibilityStore(ref)); | ||
// use reactive boolean property as $isVisible | ||
</script> |
Sorry, the diff of this file is not supported yet
174247
258
3428