@solid-primitives/mouse
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -29,3 +29,3 @@ import { ClearListeners } from '@solid-primitives/event-listener'; | ||
* | ||
* @see https://github.com/davedbase/solid-primitives/tree/main/packages/mouse#createmouseposition | ||
* @see https://github.com/solidjs-community/solid-primitives/tree/main/packages/mouse#createmouseposition | ||
* | ||
@@ -43,2 +43,20 @@ * @example | ||
]; | ||
interface Position { | ||
x: number; | ||
y: number; | ||
} | ||
interface RelativeToElementValues extends Position { | ||
top: number; | ||
left: number; | ||
width: number; | ||
height: number; | ||
} | ||
/** | ||
* Turn position relative to the page, into position relative to an element. | ||
*/ | ||
declare const posRelativeToElement: (pageX: number, pageY: number, el: Element) => RelativeToElementValues; | ||
/** | ||
* Turn position relative to the page, into position relative to the screen. | ||
*/ | ||
declare const posRelativeToScreen: (pageX: number, pageY: number) => Position; | ||
@@ -77,3 +95,3 @@ interface MouseOnScreenOptions { | ||
* | ||
* @see https://github.com/davedbase/solid-primitives/tree/main/packages/mouse#createmouseinelement | ||
* @see https://github.com/solidjs-community/solid-primitives/tree/main/packages/mouse#createmouseinelement | ||
* | ||
@@ -105,3 +123,3 @@ * @example | ||
* | ||
* @see https://github.com/davedbase/solid-primitives/tree/main/packages/mouse#createmousetoelement | ||
* @see https://github.com/solidjs-community/solid-primitives/tree/main/packages/mouse#createmousetoelement | ||
* | ||
@@ -127,21 +145,2 @@ * @example | ||
interface Position { | ||
x: number; | ||
y: number; | ||
} | ||
interface RelativeToElementValues extends Position { | ||
top: number; | ||
left: number; | ||
width: number; | ||
height: number; | ||
} | ||
/** | ||
* Turn position relative to the page, into position relative to an element. | ||
*/ | ||
declare const posRelativeToElement: (pageX: number, pageY: number, el: Element) => RelativeToElementValues; | ||
/** | ||
* Turn position relative to the page, into position relative to the screen. | ||
*/ | ||
declare const posRelativeToScreen: (pageX: number, pageY: number) => Position; | ||
export { InitialValues, MouseOnScreenOptions, MouseOptions, MouseSourceType, Position, PositionToElementOptions, RelativeToElementValues, createMouseInElement, createMouseOnScreen, createMousePosition, createMouseToElement, posRelativeToElement, posRelativeToScreen }; |
@@ -52,2 +52,17 @@ // src/mousePosition.ts | ||
} | ||
var posRelativeToElement = (pageX, pageY, el) => { | ||
const bounds = el.getBoundingClientRect(), top = bounds.top + window.screenY, left = bounds.left + window.scrollX; | ||
return { | ||
x: pageX - left, | ||
y: pageY - top, | ||
top, | ||
left, | ||
width: bounds.width, | ||
height: bounds.height | ||
}; | ||
}; | ||
var posRelativeToScreen = (pageX, pageY) => ({ | ||
x: pageX - window.scrollX, | ||
y: pageY - window.screenY | ||
}); | ||
@@ -138,3 +153,3 @@ // src/mouseOnScreen.ts | ||
// src/mouseToElement.ts | ||
import { omit } from "@solid-primitives/utils/fp"; | ||
import { omit } from "@solid-primitives/immutable"; | ||
import { access as access2 } from "@solid-primitives/utils"; | ||
@@ -193,19 +208,2 @@ import { batch as batch2, createComputed as createComputed2, createMemo as createMemo2, createSignal as createSignal4, onMount as onMount2 } from "solid-js"; | ||
} | ||
// src/index.ts | ||
var posRelativeToElement = (pageX, pageY, el) => { | ||
const bounds = el.getBoundingClientRect(), top = bounds.top + window.screenY, left = bounds.left + window.scrollX; | ||
return { | ||
x: pageX - left, | ||
y: pageY - top, | ||
top, | ||
left, | ||
width: bounds.width, | ||
height: bounds.height | ||
}; | ||
}; | ||
var posRelativeToScreen = (pageX, pageY) => ({ | ||
x: pageX - window.scrollX, | ||
y: pageY - window.screenY | ||
}); | ||
export { | ||
@@ -212,0 +210,0 @@ createMouseInElement, |
{ | ||
"name": "@solid-primitives/mouse", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "A collection of Solid Primitives, that capture current mouse cursor position, and help to deal with common related usecases.", | ||
"author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>", | ||
"license": "MIT", | ||
"homepage": "https://github.com/davedbase/solid-primitives/tree/main/packages/mouse#readme", | ||
"homepage": "https://github.com/solidjs-community/solid-primitives/tree/main/packages/mouse#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/davedbase/solid-primitives.git" | ||
"url": "git+https://github.com/solidjs-community/solid-primitives.git" | ||
}, | ||
@@ -45,11 +45,12 @@ "primitive": { | ||
"devDependencies": { | ||
"jsdom": "^19.0.0", | ||
"@solid-primitives/raf": "^1.0.5", | ||
"prettier": "^2.4.1", | ||
"solid-register": "0.1.1", | ||
"solid-register": "^0.1.5", | ||
"tslib": "^2.3.1", | ||
"tsup": "^5.10.0", | ||
"unocss": "^0.12.4", | ||
"unocss": "0.24.3", | ||
"uvu": "^0.5.2", | ||
"vite": "2.6.14", | ||
"vite-plugin-solid": "2.2.1" | ||
"vite": "2.8.1", | ||
"vite-plugin-solid": "2.2.5" | ||
}, | ||
@@ -61,4 +62,5 @@ "peerDependencies": { | ||
"@solid-primitives/event-listener": "^1.4.1", | ||
"@solid-primitives/utils": "0.1.2" | ||
"@solid-primitives/utils": "0.5.3", | ||
"@solid-primitives/immutable": "^0.0.110" | ||
} | ||
} |
@@ -6,3 +6,3 @@ # @solid-primitives/mouse | ||
[![size](https://img.shields.io/npm/v/@solid-primitives/mouse?style=for-the-badge)](https://www.npmjs.com/package/@solid-primitives/mouse) | ||
[![stage](https://img.shields.io/endpoint?style=for-the-badge&url=https%3A%2F%2Fraw.githubusercontent.com%2Fdavedbase%2Fsolid-primitives%2Fmain%2Fassets%2Fbadges%2Fstage-2.json)](https://github.com/davedbase/solid-primitives#contribution-process) | ||
[![stage](https://img.shields.io/endpoint?style=for-the-badge&url=https%3A%2F%2Fraw.githubusercontent.com%2Fsolidjs-community%2Fsolid-primitives%2Fmain%2Fassets%2Fbadges%2Fstage-2.json)](https://github.com/solidjs-community/solid-primitives#contribution-process) | ||
@@ -9,0 +9,0 @@ A collection of primitives, capturing current mouse cursor position, and helping to deal with common usecases: |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
30485
4
10
581
1
+ Added@solid-primitives/immutable@0.0.110(transitive)
+ Added@solid-primitives/utils@0.2.20.5.3(transitive)
- Removed@solid-primitives/utils@0.1.2(transitive)
- Removedsolid-js@1.3.0(transitive)