@solid-primitives/mouse
Advanced tools
Comparing version 2.0.10 to 2.0.11
import { makeEventListenerStack } from '@solid-primitives/event-listener'; | ||
import { noop, clamp, createStaticStore } from '@solid-primitives/utils'; | ||
import { noop, clamp, asAccessor } from '@solid-primitives/utils'; | ||
import { isServer } from 'solid-js/web'; | ||
import { createHydratableSingletonRoot } from '@solid-primitives/rootless'; | ||
import { createEffect, sharedConfig, onMount, createComputed } from 'solid-js'; | ||
import { createStaticStore, createDerivedStaticStore } from '@solid-primitives/static-store'; | ||
import { createEffect, sharedConfig, createSignal, onMount } from 'solid-js'; | ||
@@ -125,24 +126,14 @@ // src/common.ts | ||
} | ||
const isFn = typeof element === "function"; | ||
const calcState = (el) => { | ||
const isFn = typeof element === "function", isHydrating = sharedConfig.context, getEl = asAccessor(element), [shouldFallback, setShouldFallback] = createSignal(!!isHydrating, { equals: false }); | ||
if (isHydrating || isFn) | ||
onMount(() => setShouldFallback(false)); | ||
return createDerivedStaticStore(() => { | ||
let el; | ||
if (shouldFallback() || !(el = getEl())) | ||
return fallback; | ||
const { x, y } = pos(); | ||
return getPositionToElement(x, y, el); | ||
}; | ||
const [state, setState] = createStaticStore( | ||
isFn || sharedConfig.context ? fallback : calcState(element) | ||
); | ||
const getState = isFn ? () => { | ||
const el = element(); | ||
return el ? calcState(el) : fallback; | ||
} : calcState.bind(void 0, element), updateState = () => setState(getState()); | ||
if (sharedConfig.context) { | ||
onMount(() => createComputed(updateState)); | ||
} else { | ||
createComputed(updateState); | ||
if (isFn) | ||
onMount(updateState); | ||
} | ||
return state; | ||
}); | ||
} | ||
export { createMousePosition, createPositionToElement, getPositionInElement, getPositionToElement, getPositionToScreen, makeMouseInsideListener, makeMousePositionListener, useMousePosition }; |
{ | ||
"name": "@solid-primitives/mouse", | ||
"version": "2.0.10", | ||
"version": "2.0.11", | ||
"description": "A collection of Solid Primitives, that capture current mouse cursor position, and help to deal with common related usecases.", | ||
@@ -46,8 +46,9 @@ "author": "Damian Tarnawski <gthetarnav@gmail.com>", | ||
"devDependencies": { | ||
"@solid-primitives/raf": "^2.1.9" | ||
"@solid-primitives/raf": "^2.1.10" | ||
}, | ||
"dependencies": { | ||
"@solid-primitives/event-listener": "^2.2.9", | ||
"@solid-primitives/rootless": "^1.3.1", | ||
"@solid-primitives/utils": "^5.5.1" | ||
"@solid-primitives/event-listener": "^2.2.10", | ||
"@solid-primitives/rootless": "^1.3.2", | ||
"@solid-primitives/static-store": "^0.0.2", | ||
"@solid-primitives/utils": "^6.0.0" | ||
}, | ||
@@ -54,0 +55,0 @@ "peerDependencies": { |
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
23856
5
408
+ Added@solid-primitives/static-store@0.0.2(transitive)
- Removed@solid-primitives/utils@5.5.2(transitive)