@solid-primitives/mouse
Advanced tools
Comparing version 2.0.19 to 2.0.20
@@ -37,3 +37,3 @@ import { Position, MaybeAccessor } from '@solid-primitives/utils'; | ||
* ```ts | ||
* HTMLElement | Window | Document | ||
* SVGSVGElement | HTMLElement | Window | Document | ||
* ``` | ||
@@ -44,3 +44,3 @@ * @param callback function fired on every position change | ||
*/ | ||
declare function makeMousePositionListener(target: HTMLElement | Window | Document | undefined, callback: (position: MousePosition) => void, options?: UseTouchOptions & FollowTouchOptions): VoidFunction; | ||
declare function makeMousePositionListener(target: (SVGSVGElement | HTMLElement | Window | Document) | undefined, callback: (position: MousePosition) => void, options?: UseTouchOptions & FollowTouchOptions): VoidFunction; | ||
/** | ||
@@ -50,3 +50,3 @@ * Attaches event listeners to provided targat, listening for mouse/touch entering/leaving the element. | ||
* ```ts | ||
* HTMLElement | Window | Document | ||
* SVGSVGElement | HTMLElement | Window | Document | ||
* ``` | ||
@@ -57,3 +57,3 @@ * @param callback function fired on mouse leaving or entering the element | ||
*/ | ||
declare function makeMouseInsideListener(target: HTMLElement | Window | Document | undefined, callback: (isInside: boolean) => void, options?: UseTouchOptions): VoidFunction; | ||
declare function makeMouseInsideListener(target: (SVGSVGElement | HTMLElement | Window | Document) | undefined, callback: (isInside: boolean) => void, options?: UseTouchOptions): VoidFunction; | ||
/** | ||
@@ -102,3 +102,3 @@ * Turn position relative to the page, into position relative to an element. | ||
*/ | ||
declare function createMousePosition(target?: MaybeAccessor<Window | Document | HTMLElement>, options?: MousePositionOptions): MousePositionInside; | ||
declare function createMousePosition(target?: MaybeAccessor<SVGSVGElement | HTMLElement | Window | Document>, options?: MousePositionOptions): MousePositionInside; | ||
/** | ||
@@ -140,2 +140,2 @@ * Attaches event listeners to `window` to provide a reactive object of current mouse position on the page. | ||
export { FollowTouchOptions, MousePosition, MousePositionInside, MousePositionOptions, MouseSourceType, PositionRelativeToElement, PositionToElementOptions, UseTouchOptions, createMousePosition, createPositionToElement, getPositionInElement, getPositionToElement, getPositionToScreen, makeMouseInsideListener, makeMousePositionListener, useMousePosition }; | ||
export { type FollowTouchOptions, type MousePosition, type MousePositionInside, type MousePositionOptions, type MouseSourceType, type PositionRelativeToElement, type PositionToElementOptions, type UseTouchOptions, createMousePosition, createPositionToElement, getPositionInElement, getPositionToElement, getPositionToScreen, makeMouseInsideListener, makeMousePositionListener, useMousePosition }; |
@@ -40,4 +40,3 @@ import { makeEventListenerStack } from '@solid-primitives/event-listener'; | ||
listen("touchstart", handleTouch); | ||
if (followTouch) | ||
listen("touchmove", handleTouch); | ||
if (followTouch) listen("touchmove", handleTouch); | ||
} | ||
@@ -110,6 +109,4 @@ return clear; | ||
}; | ||
if (typeof target !== "function") | ||
attachListeners(target); | ||
else | ||
createEffect(() => attachListeners(target())); | ||
if (typeof target !== "function") attachListeners(target); | ||
else createEffect(() => attachListeners(target())); | ||
return state; | ||
@@ -129,8 +126,6 @@ } | ||
const isFn = typeof element === "function", isHydrating = sharedConfig.context, getEl = asAccessor(element), [shouldFallback, setShouldFallback] = createSignal(!!isHydrating, { equals: false }); | ||
if (isHydrating || isFn) | ||
onMount(() => setShouldFallback(false)); | ||
if (isHydrating || isFn) onMount(() => setShouldFallback(false)); | ||
return createDerivedStaticStore(() => { | ||
let el; | ||
if (shouldFallback() || !(el = getEl())) | ||
return fallback; | ||
if (shouldFallback() || !(el = getEl())) return fallback; | ||
const { x, y } = pos(); | ||
@@ -137,0 +132,0 @@ return getPositionToElement(x, y, el); |
{ | ||
"name": "@solid-primitives/mouse", | ||
"version": "2.0.19", | ||
"version": "2.0.20", | ||
"description": "A collection of Solid Primitives, that capture current mouse cursor position, and help to deal with common related usecases.", | ||
@@ -50,7 +50,7 @@ "author": "Damian Tarnawski <gthetarnav@gmail.com>", | ||
"solid-js": "^1.8.7", | ||
"@solid-primitives/raf": "^2.1.16" | ||
"@solid-primitives/raf": "^2.2.0" | ||
}, | ||
"dependencies": { | ||
"@solid-primitives/rootless": "^1.4.5", | ||
"@solid-primitives/event-listener": "^2.3.3", | ||
"@solid-primitives/rootless": "^1.4.5", | ||
"@solid-primitives/static-store": "^0.0.8", | ||
@@ -57,0 +57,0 @@ "@solid-primitives/utils": "^6.2.3" |
@@ -16,15 +16,15 @@ <p> | ||
- [`createMousePosition`](#createMousePosition) - Listens to the mouse events, providing a reactive up-to-date position of the cursor on the page. | ||
- [`createPositionToElement`](#createPositionToElement) - Provides an auto-updating position relative to a provided element. | ||
- [`createMousePosition`](#createmouseposition) - Listens to the mouse events, providing a reactive up-to-date position of the cursor on the page. | ||
- [`createPositionToElement`](#createpositiontoelement) - Provides an auto-updating position relative to a provided element. | ||
##### Non-reactive primitives: | ||
- [`makeMousePositionListener`](#makeMousePositionListener) - Attaches event listeners to provided target, listening for changes to the mouse/touch position. | ||
- [`makeMouseInsideListener`](#makeMouseInsideListener) - Attaches event listeners to provided target, listening for mouse/touch entering/leaving the element. | ||
- [`makeMousePositionListener`](#makemousepositionlistener) - Attaches event listeners to provided target, listening for changes to the mouse/touch position. | ||
- [`makeMouseInsideListener`](#makemouseinsidelistener) - Attaches event listeners to provided target, listening for mouse/touch entering/leaving the element. | ||
##### Calculations: | ||
- [`getPositionToElement`](#getPositionToElement) - Turn position relative to the page, into position relative to an element. | ||
- [`getPositionInElement`](#getPositionInElement) - Turn position relative to the page, into position relative to an element. Clamped to the element bounds. | ||
- [`getPositionToScreen`](#getPositionToScreen) - Turn position relative to the page, into position relative to the screen. | ||
- [`getPositionToElement`](#getpositiontoelement) - Turn position relative to the page, into position relative to an element. | ||
- [`getPositionInElement`](#getpositioninelement) - Turn position relative to the page, into position relative to an element. Clamped to the element bounds. | ||
- [`getPositionToScreen`](#getpositiontoscreen) - Turn position relative to the page, into position relative to the screen. | ||
@@ -36,2 +36,4 @@ ## Installation | ||
# or | ||
pnpm add @solid-primitives/mouse | ||
# or | ||
yarn add @solid-primitives/mouse | ||
@@ -89,3 +91,3 @@ ``` | ||
function createMousePosition( | ||
target?: MaybeAccessor<Window | Document | HTMLElement>, | ||
target?: MaybeAccessor<SVGSVGElement | HTMLElement | Window | Document>, | ||
options?: MousePositionOptions, | ||
@@ -92,0 +94,0 @@ ): MousePositionInside; |
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
189
29925
7
398