motion-dom
Advanced tools
Comparing version 11.18.1 to 12.0.0
@@ -343,12 +343,4 @@ 'use strict'; | ||
/** | ||
* Filter out events that are not pointer events, or are triggering | ||
* while a Motion gesture is active. | ||
*/ | ||
function filterEvents$1(callback) { | ||
return (event) => { | ||
if (event.pointerType === "touch" || isDragActive()) | ||
return; | ||
callback(event); | ||
}; | ||
function isValidHover(event) { | ||
return !(event.pointerType === "touch" || isDragActive()); | ||
} | ||
@@ -364,13 +356,17 @@ /** | ||
const [elements, eventOptions, cancel] = setupGesture(elementOrSelector, options); | ||
const onPointerEnter = filterEvents$1((enterEvent) => { | ||
const onPointerEnter = (enterEvent) => { | ||
if (!isValidHover(enterEvent)) | ||
return; | ||
const { target } = enterEvent; | ||
const onHoverEnd = onHoverStart(enterEvent); | ||
const onHoverEnd = onHoverStart(target, enterEvent); | ||
if (typeof onHoverEnd !== "function" || !target) | ||
return; | ||
const onPointerLeave = filterEvents$1((leaveEvent) => { | ||
const onPointerLeave = (leaveEvent) => { | ||
if (!isValidHover(leaveEvent)) | ||
return; | ||
onHoverEnd(leaveEvent); | ||
target.removeEventListener("pointerleave", onPointerLeave); | ||
}); | ||
}; | ||
target.addEventListener("pointerleave", onPointerLeave, eventOptions); | ||
}); | ||
}; | ||
elements.forEach((element) => { | ||
@@ -500,3 +496,3 @@ element.addEventListener("pointerenter", onPointerEnter, eventOptions); | ||
isPressing.add(element); | ||
const onPressEnd = onPressStart(startEvent); | ||
const onPressEnd = onPressStart(element, startEvent); | ||
const onPointerEnd = (endEvent, success) => { | ||
@@ -503,0 +499,0 @@ window.removeEventListener("pointerup", onPointerUp); |
@@ -625,3 +625,3 @@ interface SVGAttributes { | ||
*/ | ||
type OnHoverStartEvent = (event: PointerEvent) => void | OnHoverEndEvent; | ||
type OnHoverStartEvent = (element: Element, event: PointerEvent) => void | OnHoverEndEvent; | ||
/** | ||
@@ -646,3 +646,3 @@ * A function to be called when a hover gesture ends. | ||
type OnPressEndEvent = (event: PointerEvent, info: PressGestureInfo) => void; | ||
type OnPressStartEvent = (event: PointerEvent) => OnPressEndEvent | void; | ||
type OnPressStartEvent = (element: Element, event: PointerEvent) => OnPressEndEvent | void; | ||
@@ -649,0 +649,0 @@ interface PointerEventOptions extends EventOptions { |
{ | ||
"name": "motion-dom", | ||
"version": "11.18.1", | ||
"version": "12.0.0", | ||
"author": "Matt Perry", | ||
@@ -19,3 +19,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"motion-utils": "^11.18.1" | ||
"motion-utils": "^12.0.0" | ||
}, | ||
@@ -27,3 +27,3 @@ "scripts": { | ||
}, | ||
"gitHead": "95d7d7b515c886d195aad906fa4154f075764053" | ||
"gitHead": "61d6a9be748fa01c694c1a92fb1ca12f4bcbed2c" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2
97216
2524
+ Addedmotion-utils@12.0.0(transitive)
- Removedmotion-utils@11.18.1(transitive)
Updatedmotion-utils@^12.0.0