From fd70f95224374d23157ee7c0357733102cd0df53 Mon Sep 17 00:00:00 2001 From: Alexander Neonxp Kiryukhin Date: Sun, 18 Aug 2024 13:29:54 +0300 Subject: initial --- node_modules/pigeon-maps/src/utils.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 node_modules/pigeon-maps/src/utils.ts (limited to 'node_modules/pigeon-maps/src/utils.ts') diff --git a/node_modules/pigeon-maps/src/utils.ts b/node_modules/pigeon-maps/src/utils.ts new file mode 100644 index 0000000..ae80350 --- /dev/null +++ b/node_modules/pigeon-maps/src/utils.ts @@ -0,0 +1,25 @@ +export function debounce any>(func: T, wait: number) { + let timeout: ReturnType + return function (this: any, ...args: Parameters) { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const context = this + clearTimeout(timeout) + timeout = setTimeout(() => func.apply(context, args), wait) + } +} + +export function parentHasClass(element: HTMLElement, className: string) { + while (element) { + if (element.classList && element.classList.contains(className)) { + return true + } + element = element.parentElement + } + + return false +} + +export function parentPosition(element: HTMLElement) { + const rect = element.getBoundingClientRect() + return { x: rect.left, y: rect.top } +} -- cgit v1.2.3