Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@af-utils/scrollend-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@af-utils/scrollend-polyfill - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

lib/bundlesizes.d.ts

112

lib/index.js

@@ -1,42 +0,76 @@

const t = "scrollend";
let n = !1;
if (!n && "undefined" != typeof window && !("on" + t in window)) {
n = !0;
const e = new Event(t), o = new Set, s = new WeakMap;
let i = null;
const c = t => t.dispatchEvent(e);
addEventListener("touchstart", (t => {
for (const n of t.changedTouches) o.add(n.identifier);
}), {
passive: !0
}), addEventListener("touchend", (t => {
for (const n of t.changedTouches) o.delete(n.identifier) && i && !o.size && (c(i),
i = null);
}), {
passive: !0
});
const l = (t, n) => {
let e = 0;
const o = () => clearTimeout(e), s = () => {
o(), e = setTimeout(t, n);
"use strict";
const SCROLL_DEBOUNCE_INTERVAL = 100;
const SCROLLEND_EVENT = "scrollend";
let set = false;
if (!set &&
typeof window !== "undefined" &&
!("on" + SCROLLEND_EVENT in window)) {
set = true;
const dispatchedEvent = new Event(SCROLLEND_EVENT);
const pointers = new Set();
const handlersMap = new WeakMap();
let lastTarget = null;
const dispatchScrollEvent = (target) => target.dispatchEvent(dispatchedEvent);
addEventListener("touchstart", e => {
for (const touch of e.changedTouches) {
pointers.add(touch.identifier);
}
}, { passive: true });
addEventListener("touchend", e => {
for (const touch of e.changedTouches) {
if (pointers.delete(touch.identifier) &&
lastTarget &&
!pointers.size) {
dispatchScrollEvent(lastTarget);
lastTarget = null;
}
}
}, { passive: true });
const debounce = (fn, delay) => {
let timer = 0;
const cancel = () => clearTimeout(timer);
const result = () => {
cancel();
timer = setTimeout(fn, delay);
};
return s.t = o, s;
}, d = (n, e, o) => n.forEach((n => {
const s = n[e];
n[e] = function() {
s.apply(this, arguments), arguments[0] === t && o.apply(this, arguments);
result._cancel = cancel;
return result;
};
const patchScrollEnd = (objects, method, fn) => objects.forEach(object => {
const originalMethod = object[method];
object[method] = function () {
originalMethod.apply(this, arguments);
if (arguments[0] === SCROLLEND_EVENT) {
fn.apply(this, arguments);
}
};
})), r = [ HTMLElement.prototype, window, document ];
d(r, "addEventListener", (function(t, n, e) {
const d = l((() => {
0 === o.size ? c(this) : i = this;
}), 100);
s.set(n, d), this.addEventListener("scroll", d, e);
})), d(r, "removeEventListener", (function(t, n, e) {
const o = s.get(n);
o && (o.t(), s.delete(n), i === this && (i = null), this.removeEventListener("scroll", o, e));
}));
});
const targets = [
HTMLElement.prototype,
window,
document
];
patchScrollEnd(targets, "addEventListener", function (type, listener, options) {
const fn = debounce(() => {
if (pointers.size === 0) {
dispatchScrollEvent(this);
}
else {
lastTarget = this;
}
}, SCROLL_DEBOUNCE_INTERVAL);
handlersMap.set(listener, fn);
this.addEventListener("scroll", fn, options);
});
patchScrollEnd(targets, "removeEventListener", function (type, listener, options) {
const fn = handlersMap.get(listener);
if (fn) {
fn._cancel();
handlersMap.delete(listener);
if (lastTarget === this) {
lastTarget = null;
}
this.removeEventListener("scroll", fn, options);
}
});
}
//# sourceMappingURL=index.js.map
{
"name": "@af-utils/scrollend-polyfill",
"private": false,
"version": "0.0.10",
"version": "0.0.11",
"description": "Polyfill for scrollend event",
"repository": "https://github.com/nowaalex/af-utils.git",
"repository": {
"type": "git",
"url": "https://github.com/nowaalex/af-utils.git",
"directory": "packages/polyfills/scrollend-polyfill"
},
"homepage": "https://af-utils.com/scrollend-polyfill",
"bugs": "https://github.com/nowaalex/af-utils/issues",
"homepage": "https://af-utils.vercel.app/",
"author": "Alex Fomin <nowaalex@gmail.com> (https://github.com/nowaalex/)",
"author": {
"name": "Alex Fomin",
"email": "nowaalex@gmail.com",
"url": "https://github.com/nowaalex/"
},
"license": "MIT",

@@ -16,4 +24,15 @@ "files": [

"types": "lib/index.d.ts",
"browser": "lib/index.js",
"main": "lib/index.js",
"exports": {
"./README.md": "./README.md",
"./bundlesizes": {
"types": "./lib/bundlesizes.d.ts",
"default": "./lib/bundlesizes.js"
},
".": {
"types": "./lib/index.d.ts",
"node": "./lib/index.js",
"default": "./lib/index.js"
}
},
"keywords": [

@@ -24,6 +43,4 @@ "scrollend",

"devDependencies": {
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"rollup": "^4.9.6",
"@af-utils/rollup-plugin-export-bundle-size": "0.0.5"
"typescript": "^5.4.5",
"@af-utils/export-bundle-size": "0.0.5"
},

@@ -34,5 +51,6 @@ "publishConfig": {

"scripts": {
"dev": "rollup --w --c rollup.config.ts --configPlugin typescript",
"build": "rollup --c rollup.config.ts --configPlugin typescript"
"dev": "tsc -w && pnpm export-bundle-size",
"build": "tsc && pnpm export-bundle-size",
"export-bundle-size": "export-bundle-size -i ./lib/index.js -o ./lib/bundlesizes.js"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc