@solid-primitives/resize-observer
Advanced tools
Comparing version 2.0.6 to 2.0.7
@@ -84,3 +84,3 @@ import { Accessor } from 'solid-js'; | ||
*/ | ||
declare function createElementSize(target: MaybeAccessor<Element>): { | ||
declare function createElementSize(target: Element): { | ||
readonly width: number; | ||
@@ -87,0 +87,0 @@ readonly height: number; |
import { onCleanup, $PROXY, createEffect, on, onMount, $TRACK } from 'solid-js'; | ||
import { asArray, handleDiffArray, createStaticStore, access } from '@solid-primitives/utils'; | ||
import { asArray, handleDiffArray, createStaticStore } from '@solid-primitives/utils'; | ||
import { createSharedRoot } from '@solid-primitives/rootless'; | ||
@@ -61,6 +61,3 @@ import { makeEventListener } from '@solid-primitives/event-listener'; | ||
if (!target) | ||
return { | ||
width: null, | ||
height: null | ||
}; | ||
return { width: null, height: null }; | ||
const { width, height } = target.getBoundingClientRect(); | ||
@@ -70,5 +67,8 @@ return { width, height }; | ||
function createElementSize(target) { | ||
const [size, setSize] = createStaticStore(getElementSize(access(target))); | ||
if (typeof target === "function") | ||
onMount(() => setSize(getElementSize(target()))); | ||
const [size, setSize] = createStaticStore( | ||
typeof target !== "function" ? getElementSize(target) : (() => { | ||
onMount(() => setSize(getElementSize(target()))); | ||
return { width: null, height: null }; | ||
})() | ||
); | ||
const updateSize = (e) => setSize({ width: e.width, height: e.height }); | ||
@@ -75,0 +75,0 @@ createResizeObserver(typeof target === "function" ? () => target() || [] : target, updateSize); |
@@ -30,6 +30,3 @@ import 'solid-js'; | ||
function getElementSize(target) { | ||
return { | ||
width: null, | ||
height: null | ||
}; | ||
return { width: null, height: null }; | ||
} | ||
@@ -36,0 +33,0 @@ function createElementSize(target) { |
{ | ||
"name": "@solid-primitives/resize-observer", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"description": "Reactive primitives for observing resizing of HTML elements.", | ||
@@ -69,5 +69,2 @@ "author": "Moshe Udimar", | ||
}, | ||
"devDependencies": { | ||
"solid-js": "^1.6.0" | ||
}, | ||
"peerDependencies": { | ||
@@ -74,0 +71,0 @@ "solid-js": "^1.6.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
0
20199
330