@zag-js/dom-utils
Advanced tools
Comparing version 0.0.0-dev-20230102084517 to 0.0.0-dev-20230105173950
@@ -62,5 +62,5 @@ "use strict"; | ||
function getPointPercentRelativeToNode(point, element) { | ||
const pt = getPointRelativeToNode(point, element); | ||
const x = pt.x / element.offsetWidth * 100; | ||
const y = pt.y / element.offsetHeight * 100; | ||
const relativePoint = getPointRelativeToNode(point, element); | ||
const x = relativePoint.x / element.offsetWidth * 100; | ||
const y = relativePoint.y / element.offsetHeight * 100; | ||
return { x: clampPercent(x), y: clampPercent(y) }; | ||
@@ -67,0 +67,0 @@ } |
@@ -309,21 +309,3 @@ "use strict"; | ||
getActiveElement: (ctx) => dom.getDoc(ctx).activeElement, | ||
getById: (ctx, id) => dom.getRootNode(ctx).getElementById(id), | ||
createEmitter: (ctx, target) => { | ||
const win = dom.getWin(ctx); | ||
return function emit(evt, detail, options) { | ||
const { bubbles = true, cancelable, composed = true } = options != null ? options : {}; | ||
const eventName = `zag:${evt}`; | ||
const init = { bubbles, cancelable, composed, detail }; | ||
const event = new win.CustomEvent(eventName, init); | ||
target.dispatchEvent(event); | ||
}; | ||
}, | ||
createListener: (target) => { | ||
return function listen(evt, handler) { | ||
const eventName = `zag:${evt}`; | ||
const listener = (e) => handler(e); | ||
target.addEventListener(eventName, listener); | ||
return () => target.removeEventListener(eventName, listener); | ||
}; | ||
} | ||
getById: (ctx, id) => dom.getRootNode(ctx).getElementById(id) | ||
}; | ||
@@ -535,5 +517,5 @@ return { | ||
function getPointPercentRelativeToNode(point, element) { | ||
const pt2 = getPointRelativeToNode(point, element); | ||
const x = pt2.x / element.offsetWidth * 100; | ||
const y = pt2.y / element.offsetHeight * 100; | ||
const relativePoint = getPointRelativeToNode(point, element); | ||
const x = relativePoint.x / element.offsetWidth * 100; | ||
const y = relativePoint.y / element.offsetHeight * 100; | ||
return { x: clampPercent(x), y: clampPercent(y) }; | ||
@@ -887,3 +869,6 @@ } | ||
return; | ||
body.requestPointerLock(); | ||
try { | ||
body.requestPointerLock(); | ||
} catch { | ||
} | ||
const cleanup = callAll( | ||
@@ -890,0 +875,0 @@ addPointerlockChangeListener(doc, onPointerChange), |
@@ -85,3 +85,6 @@ "use strict"; | ||
return; | ||
body.requestPointerLock(); | ||
try { | ||
body.requestPointerLock(); | ||
} catch { | ||
} | ||
const cleanup = callAll( | ||
@@ -88,0 +91,0 @@ addPointerlockChangeListener(doc, onPointerChange), |
@@ -25,4 +25,2 @@ declare function isDocument(el: any): el is Document; | ||
getById: <T_1 = HTMLElement>(ctx: Ctx, id: string) => T_1 | null; | ||
createEmitter: (ctx: Ctx, target: HTMLElement) => (evt: string, detail: Record<string, any>, options?: EventInit) => void; | ||
createListener: (target: HTMLElement) => <T_2 = any>(evt: string, handler: (e: CustomEvent<T_2>) => void) => () => void; | ||
} & T; | ||
@@ -29,0 +27,0 @@ declare function contains(parent: HTMLElement | EventTarget | null | undefined, child: HTMLElement | EventTarget | null): boolean; |
@@ -132,21 +132,3 @@ "use strict"; | ||
getActiveElement: (ctx) => dom.getDoc(ctx).activeElement, | ||
getById: (ctx, id) => dom.getRootNode(ctx).getElementById(id), | ||
createEmitter: (ctx, target) => { | ||
const win = dom.getWin(ctx); | ||
return function emit(evt, detail, options) { | ||
const { bubbles = true, cancelable, composed = true } = options != null ? options : {}; | ||
const eventName = `zag:${evt}`; | ||
const init = { bubbles, cancelable, composed, detail }; | ||
const event = new win.CustomEvent(eventName, init); | ||
target.dispatchEvent(event); | ||
}; | ||
}, | ||
createListener: (target) => { | ||
return function listen(evt, handler) { | ||
const eventName = `zag:${evt}`; | ||
const listener = (e) => handler(e); | ||
target.addEventListener(eventName, listener); | ||
return () => target.removeEventListener(eventName, listener); | ||
}; | ||
} | ||
getById: (ctx, id) => dom.getRootNode(ctx).getElementById(id) | ||
}; | ||
@@ -153,0 +135,0 @@ return { |
{ | ||
"name": "@zag-js/dom-utils", | ||
"version": "0.0.0-dev-20230102084517", | ||
"version": "0.0.0-dev-20230105173950", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
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
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
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
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
183978
5680