summaryrefslogtreecommitdiff
path: root/node_modules/pigeon-maps/src/utils.ts
diff options
context:
space:
mode:
authorAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-08-18 13:29:54 +0300
committerAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-08-18 13:29:54 +0300
commitfd70f95224374d23157ee7c0357733102cd0df53 (patch)
treee490c12e021cedaf211b292d5d623baa32a673fc /node_modules/pigeon-maps/src/utils.ts
initialHEADmaster
Diffstat (limited to 'node_modules/pigeon-maps/src/utils.ts')
-rw-r--r--node_modules/pigeon-maps/src/utils.ts25
1 files changed, 25 insertions, 0 deletions
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<T extends (...args: any[]) => any>(func: T, wait: number) {
+ let timeout: ReturnType<typeof setTimeout>
+ return function (this: any, ...args: Parameters<T>) {
+ // 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 }
+}