@zag-js/dom-utils
Advanced tools
Comparing version 0.0.0-dev-20220626173054 to 0.0.0-dev-20220626175355
@@ -6,5 +6,4 @@ /// <reference types="react" /> | ||
export declare function getNativeEvent<E>(e: E): NativeEvent<E>; | ||
export declare function queueBeforeEvent(el: Element, type: string, fn: VoidFunction): number; | ||
export declare function isPortalEvent(event: Pick<Event, "currentTarget" | "target">): boolean; | ||
export declare function isSelfTarget(event: Pick<Event, "target" | "currentTarget">): boolean; | ||
export {}; |
@@ -275,2 +275,13 @@ "use strict"; | ||
} | ||
function queueBeforeEvent(el, type, fn) { | ||
const cleanup = raf(() => { | ||
el.removeEventListener(type, invoke, true); | ||
fn(); | ||
}); | ||
const invoke = () => { | ||
cleanup(); | ||
fn(); | ||
}; | ||
el.addEventListener(type, invoke, { once: true, capture: true }); | ||
} | ||
@@ -462,14 +473,2 @@ // src/body-pointer-event.ts | ||
} | ||
function queueBeforeEvent(el, type, fn) { | ||
const raf2 = requestAnimationFrame(() => { | ||
el.removeEventListener(type, invoke, true); | ||
fn(); | ||
}); | ||
const invoke = () => { | ||
cancelAnimationFrame(raf2); | ||
fn(); | ||
}; | ||
el.addEventListener(type, invoke, { once: true, capture: true }); | ||
return raf2; | ||
} | ||
function isPortalEvent(event) { | ||
@@ -476,0 +475,0 @@ return !contains(event.currentTarget, event.target); |
export declare function nextTick(fn: VoidFunction): () => void; | ||
export declare function raf(fn: VoidFunction): () => void; | ||
export declare function queueMicrotask(fn: VoidFunction): void; | ||
export declare function queueBeforeEvent(el: Element, type: string, fn: VoidFunction): void; |
{ | ||
"name": "@zag-js/dom-utils", | ||
"version": "0.0.0-dev-20220626173054", | ||
"version": "0.0.0-dev-20220626175355", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83132
2432