@solid-primitives/mouse
Advanced tools
Comparing version 2.0.9 to 2.0.10
import { makeEventListenerStack } from '@solid-primitives/event-listener'; | ||
import { clamp, createStaticStore } from '@solid-primitives/utils'; | ||
import { noop, clamp, createStaticStore } from '@solid-primitives/utils'; | ||
import { isServer } from 'solid-js/web'; | ||
import { createHydratableSingletonRoot } from '@solid-primitives/rootless'; | ||
@@ -24,2 +25,5 @@ import { createEffect, sharedConfig, onMount, createComputed } from 'solid-js'; | ||
function makeMousePositionListener(target = window, callback, options = {}) { | ||
if (isServer) { | ||
return noop; | ||
} | ||
const { touch = true, followTouch = true } = options; | ||
@@ -42,2 +46,5 @@ const [listen, clear] = makeEventListenerStack(target, PASSIVE); | ||
function makeMouseInsideListener(target = window, callback, options = {}) { | ||
if (isServer) { | ||
return noop; | ||
} | ||
const { touch = true } = options; | ||
@@ -61,2 +68,5 @@ const [listen, clear] = makeEventListenerStack(target, PASSIVE); | ||
var getPositionToElement = (pageX, pageY, el) => { | ||
if (isServer) { | ||
return DEFAULT_RELATIVE_ELEMENT_POSITION; | ||
} | ||
const bounds = el.getBoundingClientRect(), top = bounds.top + window.scrollY, left = bounds.left + window.scrollX, x = pageX - left, y = pageY - top, { width, height } = bounds; | ||
@@ -74,2 +84,5 @@ return { | ||
var getPositionInElement = (pageX, pageY, el) => { | ||
if (isServer) { | ||
return DEFAULT_RELATIVE_ELEMENT_POSITION; | ||
} | ||
const relative = getPositionToElement(pageX, pageY, el); | ||
@@ -82,3 +95,3 @@ return { | ||
}; | ||
var getPositionToScreen = (pageX, pageY) => ({ | ||
var getPositionToScreen = isServer ? () => DEFAULT_MOUSE_POSITION : (pageX, pageY) => ({ | ||
x: pageX - window.scrollX, | ||
@@ -92,2 +105,5 @@ y: pageY - window.screenY | ||
}; | ||
if (isServer) { | ||
return fallback; | ||
} | ||
const [state, setState] = createStaticStore(fallback); | ||
@@ -112,2 +128,5 @@ const attachListeners = (el) => { | ||
}; | ||
if (isServer) { | ||
return fallback; | ||
} | ||
const isFn = typeof element === "function"; | ||
@@ -114,0 +133,0 @@ const calcState = (el) => { |
{ | ||
"name": "@solid-primitives/mouse", | ||
"version": "2.0.9", | ||
"version": "2.0.10", | ||
"description": "A collection of Solid Primitives, that capture current mouse cursor position, and help to deal with common related usecases.", | ||
@@ -24,52 +24,7 @@ "author": "Damian Tarnawski <gthetarnav@gmail.com>", | ||
"type": "module", | ||
"main": "./dist/server.cjs", | ||
"module": "./dist/server.js", | ||
"main": "./dist/index.cjs", | ||
"module": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"browser": { | ||
"./dist/server.js": "./dist/index.js", | ||
"./dist/server.cjs": "./dist/index.cjs" | ||
}, | ||
"browser": {}, | ||
"exports": { | ||
"worker": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/server.js" | ||
}, | ||
"require": "./dist/server.cjs" | ||
}, | ||
"browser": { | ||
"development": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/dev.js" | ||
}, | ||
"require": "./dist/dev.cjs" | ||
}, | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"require": "./dist/index.cjs" | ||
}, | ||
"deno": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/server.js" | ||
}, | ||
"require": "./dist/server.cjs" | ||
}, | ||
"node": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/server.js" | ||
}, | ||
"require": "./dist/server.cjs" | ||
}, | ||
"development": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/dev.js" | ||
}, | ||
"require": "./dist/dev.cjs" | ||
}, | ||
"import": { | ||
@@ -92,11 +47,11 @@ "types": "./dist/index.d.ts", | ||
"devDependencies": { | ||
"@solid-primitives/raf": "^2.1.8" | ||
"@solid-primitives/raf": "^2.1.9" | ||
}, | ||
"dependencies": { | ||
"@solid-primitives/event-listener": "^2.2.8", | ||
"@solid-primitives/rootless": "^1.3.0", | ||
"@solid-primitives/utils": "^5.5.0" | ||
"@solid-primitives/event-listener": "^2.2.9", | ||
"@solid-primitives/rootless": "^1.3.1", | ||
"@solid-primitives/utils": "^5.5.1" | ||
}, | ||
"peerDependencies": { | ||
"solid-js": "^1.6.0" | ||
"solid-js": "^1.6.12" | ||
}, | ||
@@ -108,3 +63,3 @@ "typesVersions": {}, | ||
"page": "vite build dev", | ||
"build": "jiti ../../scripts/build.ts --ssr --dev", | ||
"build": "jiti ../../scripts/build.ts", | ||
"test": "vitest -c ../../configs/vitest.config.ts", | ||
@@ -111,0 +66,0 @@ "test:ssr": "pnpm run test --mode ssr", |
Sorry, the diff of this file is not supported yet
24002
6
426