use-scroll-animate 5.0.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/components/effects.cjs +265 -0
- package/dist/components/effects.cjs.map +1 -0
- package/dist/components/effects.d.cts +66 -0
- package/dist/components/effects.d.ts +66 -0
- package/dist/components/effects.js +258 -0
- package/dist/components/effects.js.map +1 -0
- package/dist/components/fx.cjs +14 -10
- package/dist/components/fx.cjs.map +1 -1
- package/dist/components/fx.js +14 -10
- package/dist/components/fx.js.map +1 -1
- package/dist/components/lite.cjs +14 -10
- package/dist/components/lite.cjs.map +1 -1
- package/dist/components/lite.js +14 -10
- package/dist/components/lite.js.map +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/docs/ROADMAP.md +1 -1
- package/docs/components.md +15 -0
- package/package.json +11 -1
package/dist/components/lite.js
CHANGED
|
@@ -10169,19 +10169,23 @@ function bindEffect(el, name, options = {}) {
|
|
|
10169
10169
|
if (!def)
|
|
10170
10170
|
throw new Error(`[use-scroll-animate] unknown effect "${name}"`);
|
|
10171
10171
|
const offs = [];
|
|
10172
|
+
let current = null;
|
|
10172
10173
|
const fire = (e) => {
|
|
10173
|
-
|
|
10174
|
-
|
|
10175
|
-
if (ctx.reduced && (def.reduced ?? 'skip') === 'skip')
|
|
10176
|
-
return;
|
|
10177
|
-
const out = def.run(el, { ...(def.defaults || {}), ...opts }, ctx);
|
|
10178
|
-
if (typeof out === 'function')
|
|
10179
|
-
offs.push(out);
|
|
10180
|
-
offs.push(...ctx.cleanups);
|
|
10174
|
+
const ctx = context(e);
|
|
10175
|
+
if (ctx.reduced && (def.reduced ?? (SKIP_BY_DEFAULT.includes(def.kind) ? 'skip' : 'run')) === 'skip')
|
|
10181
10176
|
return;
|
|
10182
|
-
|
|
10183
|
-
|
|
10177
|
+
// A persistent effect (returns a cleanup) replaces its previous run instead of stacking.
|
|
10178
|
+
current?.();
|
|
10179
|
+
current = null;
|
|
10180
|
+
const out = def.run(el, { ...(def.defaults || {}), ...opts }, ctx);
|
|
10181
|
+
const stops = [...ctx.cleanups, ...(typeof out === 'function' ? [out] : [])];
|
|
10182
|
+
if (stops.length)
|
|
10183
|
+
current = () => stops.splice(0).forEach((f) => f());
|
|
10184
10184
|
};
|
|
10185
|
+
offs.push(() => {
|
|
10186
|
+
current?.();
|
|
10187
|
+
current = null;
|
|
10188
|
+
});
|
|
10185
10189
|
const on = (type, opt) => {
|
|
10186
10190
|
el.addEventListener(type, fire, opt);
|
|
10187
10191
|
offs.push(() => el.removeEventListener(type, fire, opt));
|