Socket
Socket
Sign inDemoInstall

@zag-js/dom-event

Package Overview
Dependencies
Maintainers
1
Versions
671
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/dom-event - npm Package Compare versions

Comparing version 0.9.1 to 0.9.2

dist/chunk-H6S55I4B.mjs

5

dist/get-element-offset.js

@@ -30,2 +30,3 @@ "use strict";

let el = element;
const win = element.ownerDocument.defaultView || window;
if (el.parentNode) {

@@ -44,4 +45,4 @@ do {

top,
right: innerWidth - left - element.offsetWidth,
bottom: innerHeight - top - element.offsetHeight,
right: win.innerWidth - left - element.offsetWidth,
bottom: win.innerHeight - top - element.offsetHeight,
left

@@ -48,0 +49,0 @@ };

3

dist/index.d.ts

@@ -5,5 +5,6 @@ export { addDomEvent } from './add-dom-event.js';

export { getEventKey } from './get-event-key.js';
export { getEventPoint } from './get-event-point.js';
export { getEventStep } from './get-event-step.js';
export { getNativeEvent } from './get-native-event.js';
export { getRelativePointPercent, getRelativePointValue } from './point-value.js';
export { getRelativePointPercent, getRelativePointValue } from './get-point-value.js';
export { requestPointerLock } from './request-pointer-lock.js';

@@ -10,0 +11,0 @@ export { trackPointerMove } from './track-pointer-move.js';

@@ -27,2 +27,3 @@ "use strict";

getEventKey: () => getEventKey,
getEventPoint: () => getEventPoint,
getEventStep: () => getEventStep,

@@ -120,2 +121,15 @@ getNativeEvent: () => getNativeEvent,

// src/get-event-point.ts
function pointFromTouch(e, type = "page") {
const point = e.touches[0] || e.changedTouches[0];
return { x: point[`${type}X`], y: point[`${type}Y`] };
}
function pointFromMouse(point, type = "page") {
return { x: point[`${type}X`], y: point[`${type}Y`] };
}
var isTouchEvent = (event) => "touches" in event && event.touches.length > 0;
function getEventPoint(event, type = "page") {
return isTouchEvent(event) ? pointFromTouch(event, type) : pointFromMouse(event, type);
}
// src/get-event-step.ts

@@ -144,2 +158,3 @@ var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);

let el = element;
const win = element.ownerDocument.defaultView || window;
if (el.parentNode) {

@@ -158,4 +173,4 @@ do {

top,
right: innerWidth - left - element.offsetWidth,
bottom: innerHeight - top - element.offsetHeight,
right: win.innerWidth - left - element.offsetWidth,
bottom: win.innerHeight - top - element.offsetHeight,
left

@@ -165,3 +180,3 @@ };

// src/point-value.ts
// src/get-point-value.ts
var clamp = (value) => Math.max(0, Math.min(1, value));

@@ -232,5 +247,4 @@ function getRelativePointValue(absolutePoint, element) {

const handleMove = (event) => {
const x = event.clientX;
const y = event.clientY;
const distance = Math.sqrt(x ** 2 + y ** 2);
const point = getEventPoint(event);
const distance = Math.sqrt(point.x ** 2 + point.y ** 2);
const moveBuffer = event.pointerType === "touch" ? 10 : 5;

@@ -243,3 +257,3 @@ if (distance < moveBuffer)

}
onPointerMove({ point: { x, y }, event });
onPointerMove({ point, event });
};

@@ -279,2 +293,3 @@ const cleanups = [

getEventKey,
getEventPoint,
getEventStep,

@@ -281,0 +296,0 @@ getNativeEvent,

@@ -37,2 +37,15 @@ "use strict";

// src/get-event-point.ts
function pointFromTouch(e, type = "page") {
const point = e.touches[0] || e.changedTouches[0];
return { x: point[`${type}X`], y: point[`${type}Y`] };
}
function pointFromMouse(point, type = "page") {
return { x: point[`${type}X`], y: point[`${type}Y`] };
}
var isTouchEvent = (event) => "touches" in event && event.touches.length > 0;
function getEventPoint(event, type = "page") {
return isTouchEvent(event) ? pointFromTouch(event, type) : pointFromMouse(event, type);
}
// src/track-pointer-move.ts

@@ -42,5 +55,4 @@ function trackPointerMove(doc, handlers) {

const handleMove = (event) => {
const x = event.clientX;
const y = event.clientY;
const distance = Math.sqrt(x ** 2 + y ** 2);
const point = getEventPoint(event);
const distance = Math.sqrt(point.x ** 2 + point.y ** 2);
const moveBuffer = event.pointerType === "touch" ? 10 : 5;

@@ -53,3 +65,3 @@ if (distance < moveBuffer)

}
onPointerMove({ point: { x, y }, event });
onPointerMove({ point, event });
};

@@ -56,0 +68,0 @@ const cleanups = [

{
"name": "@zag-js/dom-event",
"version": "0.9.1",
"version": "0.9.2",
"description": "",

@@ -27,4 +27,4 @@ "keywords": [

"dependencies": {
"@zag-js/types": "0.9.1",
"@zag-js/text-selection": "0.9.1"
"@zag-js/types": "0.9.2",
"@zag-js/text-selection": "0.9.2"
},

@@ -31,0 +31,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc