@zag-js/dom-event
Advanced tools
Comparing version 0.56.0 to 0.56.1
@@ -69,4 +69,3 @@ "use strict"; | ||
function isVirtualClick(e) { | ||
if (e.mozInputSource === 0 && e.isTrusted) | ||
return true; | ||
if (e.mozInputSource === 0 && e.isTrusted) return true; | ||
return e.detail === 0 && !e.pointerType; | ||
@@ -106,4 +105,3 @@ } | ||
function clickIfLink(element) { | ||
if (!isLinkElement(element)) | ||
return; | ||
if (!isLinkElement(element)) return; | ||
const click = () => element.click(); | ||
@@ -119,4 +117,3 @@ if ((0, import_dom_query2.isFirefox)()) { | ||
function fireCustomEvent(el, type, init) { | ||
if (!el) | ||
return; | ||
if (!el) return; | ||
const win = el.ownerDocument.defaultView || window; | ||
@@ -220,9 +217,7 @@ const event = new win.CustomEvent(type, init); | ||
function onPointerError(event) { | ||
if (isLocked()) | ||
fn?.(false); | ||
if (isLocked()) fn?.(false); | ||
console.error("PointerLock error occured:", event); | ||
doc.exitPointerLock(); | ||
} | ||
if (!supported) | ||
return; | ||
if (!supported) return; | ||
try { | ||
@@ -254,4 +249,3 @@ body.requestPointerLock(); | ||
function trackFocusVisible(node, options) { | ||
if (!node) | ||
return; | ||
if (!node) return; | ||
const { onFocus, onBlur } = options; | ||
@@ -267,4 +261,3 @@ const win = (0, import_dom_query3.getWindow)(node); | ||
} | ||
if (!isFocusVisible) | ||
return; | ||
if (!isFocusVisible) return; | ||
focused = true; | ||
@@ -274,4 +267,3 @@ onFocus?.(e); | ||
const handleBlur = (e) => { | ||
if (!focused) | ||
return; | ||
if (!focused) return; | ||
focused = false; | ||
@@ -281,4 +273,3 @@ onBlur?.(e); | ||
const handleKeydown = (e) => { | ||
if (!node.matches(":focus") || !isValidKey(e)) | ||
return; | ||
if (!node.matches(":focus") || !isValidKey(e)) return; | ||
focused = true; | ||
@@ -305,4 +296,3 @@ const evt = new win.FocusEvent("focus"); | ||
const moveBuffer = event.pointerType === "touch" ? 10 : 5; | ||
if (distance < moveBuffer) | ||
return; | ||
if (distance < moveBuffer) return; | ||
if (event.pointerType === "mouse" && event.button === 0) { | ||
@@ -336,4 +326,3 @@ onPointerUp(); | ||
function getVelocity(history, timeDelta) { | ||
if (history.length < 2) | ||
return { x: 0, y: 0 }; | ||
if (history.length < 2) return { x: 0, y: 0 }; | ||
let i = history.length - 1; | ||
@@ -349,7 +338,5 @@ let timestampedPoint = null; | ||
} | ||
if (!timestampedPoint) | ||
return { x: 0, y: 0 }; | ||
if (!timestampedPoint) return { x: 0, y: 0 }; | ||
const time = sec(lastPoint.timestamp - timestampedPoint.timestamp); | ||
if (time === 0) | ||
return { x: 0, y: 0 }; | ||
if (time === 0) return { x: 0, y: 0 }; | ||
const currentVelocity = { | ||
@@ -359,6 +346,4 @@ x: (lastPoint.x - timestampedPoint.x) / time, | ||
}; | ||
if (currentVelocity.x === Infinity) | ||
currentVelocity.x = 0; | ||
if (currentVelocity.y === Infinity) | ||
currentVelocity.y = 0; | ||
if (currentVelocity.x === Infinity) currentVelocity.x = 0; | ||
if (currentVelocity.y === Infinity) currentVelocity.y = 0; | ||
return { | ||
@@ -381,4 +366,3 @@ x: Math.abs(currentVelocity.x), | ||
} = options; | ||
if (!pointerNode) | ||
return noop; | ||
if (!pointerNode) return noop; | ||
const win = (0, import_dom_query4.getWindow)(pointerNode); | ||
@@ -422,7 +406,5 @@ const doc = (0, import_dom_query4.getDocument)(pointerNode); | ||
const handleKeydown = (keydownEvent) => { | ||
if (!isValidKey2(keydownEvent)) | ||
return; | ||
if (!isValidKey2(keydownEvent)) return; | ||
const handleKeyup = (keyupEvent) => { | ||
if (!isValidKey2(keyupEvent)) | ||
return; | ||
if (!isValidKey2(keyupEvent)) return; | ||
const evt2 = new win.PointerEvent("pointerup"); | ||
@@ -429,0 +411,0 @@ const info = getInfo(evt2); |
{ | ||
"name": "@zag-js/dom-event", | ||
"version": "0.56.0", | ||
"version": "0.56.1", | ||
"description": "", | ||
@@ -28,5 +28,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@zag-js/types": "0.56.0", | ||
"@zag-js/dom-query": "0.56.0", | ||
"@zag-js/text-selection": "0.56.0" | ||
"@zag-js/types": "0.56.1", | ||
"@zag-js/dom-query": "0.56.1", | ||
"@zag-js/text-selection": "0.56.1" | ||
}, | ||
@@ -33,0 +33,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
115043
1524
+ Added@zag-js/dom-query@0.56.1(transitive)
+ Added@zag-js/text-selection@0.56.1(transitive)
+ Added@zag-js/types@0.56.1(transitive)
- Removed@zag-js/dom-query@0.56.0(transitive)
- Removed@zag-js/text-selection@0.56.0(transitive)
- Removed@zag-js/types@0.56.0(transitive)
Updated@zag-js/dom-query@0.56.1
Updated@zag-js/types@0.56.1