@af-utils/scrollend-polyfill
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -1,4 +0,4 @@ | ||
export const raw = 1466; | ||
export const raw = 1444; | ||
export const min = 984; | ||
export const minGz = 534; | ||
export const minBrotli = 452; | ||
export const minGz = 539; | ||
export const minBrotli = 449; |
@@ -10,6 +10,5 @@ /** | ||
*/ | ||
/** | ||
* @public | ||
* Targets to monkey-patch `addEventListener` / `removeEventListener`. | ||
* debounce interval in milliseconds for attached `scroll` event. | ||
* | ||
@@ -19,7 +18,6 @@ * @remarks | ||
*/ | ||
export declare type PolyfilledTarget = HTMLElement | Window | Document; | ||
export declare const SCROLL_DEBOUNCE_INTERVAL = 100; | ||
/** | ||
* @public | ||
* debounce interval in milliseconds for attached `scroll` event. | ||
* Targets to monkey-patch `addEventListener` / `removeEventListener`. | ||
* | ||
@@ -29,4 +27,2 @@ * @remarks | ||
*/ | ||
export declare const SCROLL_DEBOUNCE_INTERVAL = 100; | ||
export { } | ||
export type PolyfilledTarget = HTMLElement | Window | Document; |
const t = 100, n = "scrollend"; | ||
if ("undefined" != typeof window && !("on" + n in window)) { | ||
const s = new Event(n), i = new Set, c = new WeakMap; | ||
let l = null; | ||
const r = t => t.dispatchEvent(s); | ||
const t = new Event(n), e = new Set, o = new WeakMap; | ||
let s = null; | ||
const i = n => n.dispatchEvent(t); | ||
addEventListener("touchstart", (t => { | ||
for (const n of t.changedTouches) i.add(n.identifier); | ||
for (const n of t.changedTouches) e.add(n.identifier); | ||
}), { | ||
passive: !0 | ||
}), addEventListener("touchend", (t => { | ||
for (const n of t.changedTouches) i.delete(n.identifier) && l && !i.size && (r(l), | ||
l = null); | ||
for (const n of t.changedTouches) e.delete(n.identifier) && s && !e.size && (i(s), | ||
s = null); | ||
}), { | ||
passive: !0 | ||
}); | ||
const d = (t, n) => { | ||
const c = (t, n) => { | ||
let e = 0; | ||
@@ -23,3 +23,3 @@ const o = () => clearTimeout(e), s = () => { | ||
return s.t = o, s; | ||
}, u = (t, e, o) => { | ||
}, l = (t, e, o) => t.forEach((t => { | ||
const s = t[e]; | ||
@@ -29,15 +29,11 @@ t[e] = function() { | ||
}; | ||
}; | ||
function e(t, n, e) { | ||
const o = d((() => { | ||
0 === i.size ? r(this) : l = this; | ||
})), r = [ HTMLElement.prototype, window, document ]; | ||
l(r, "addEventListener", (function(t, n, l) { | ||
const r = c((() => { | ||
0 === e.size ? i(this) : s = this; | ||
}), 100); | ||
c.set(n, o), this.addEventListener("scroll", o, e); | ||
} | ||
function o(t, n, e) { | ||
const o = c.get(n); | ||
o && (o.t(), c.delete(n), l === this && (l = null), this.removeEventListener("scroll", o, e)); | ||
} | ||
[ HTMLElement.prototype, window, document ].forEach((t => { | ||
u(t, "addEventListener", e), u(t, "removeEventListener", o); | ||
o.set(n, r), this.addEventListener("scroll", r, l); | ||
})), l(r, "removeEventListener", (function(t, n, e) { | ||
const i = o.get(n); | ||
i && (i.t(), o.delete(n), s === this && (s = null), this.removeEventListener("scroll", i, e)); | ||
})); | ||
@@ -44,0 +40,0 @@ } |
{ | ||
"name": "@af-utils/scrollend-polyfill", | ||
"private": false, | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Polyfill for scrollend event", | ||
@@ -29,3 +29,3 @@ "repository": "https://github.com/nowaalex/af-utils.git", | ||
"@rollup/plugin-typescript": "^11.1.5", | ||
"@types/node": "^20.8.4", | ||
"@types/node": "^20.8.5", | ||
"jest": "^29.7.0", | ||
@@ -32,0 +32,0 @@ "jest-environment-jsdom": "^29.7.0", |
Sorry, the diff of this file is not supported yet
11101
67