svg-scroll-draw 2.10.2 → 2.11.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/README.md CHANGED
@@ -30,6 +30,7 @@
30
30
  | `scrollVideo` | `svg-scroll-draw/video` | Tie `<video>.currentTime` to scroll. The Apple/Stripe product-page pattern. |
31
31
  | `scrollText` | `svg-scroll-draw/text` | Split text into chars/words/lines and stagger-animate each on scroll. 2.5 KB, nothing else to load. |
32
32
  | `devtools` | `svg-scroll-draw/devtools` | Visual overlay showing every active animation's triggers and progress. Dev-only. |
33
+ | `AOS` | `svg-scroll-draw/aos` | Drop-in replacement for AOS: same `AOS.init()`, same `data-aos` markup, no `aos.css`. |
33
34
 
34
35
  All APIs return the same instance object: `{ destroy, replay, pause, resume, seek, getProgress }`.
35
36
 
@@ -357,6 +358,45 @@ import { ScrollDraw } from 'svg-scroll-draw/vue';
357
358
 
358
359
  ---
359
360
 
361
+ ## AOS drop-in — switch from AOS in one line
362
+
363
+ Already using [AOS](https://github.com/michalsnik/aos)? `svg-scroll-draw/aos` speaks its API and
364
+ reads its markup, so the move is an import change. Keep every `data-aos`, `data-aos-offset`,
365
+ `data-aos-delay`, `data-aos-anchor-placement` and custom animation; delete `aos.css` — the styles ship
366
+ inside the module. 3.0 KB gzipped with the styles, against 6.7 KB for AOS 2.3.4 with its stylesheet.
367
+
368
+ ```diff
369
+ - import AOS from 'aos';
370
+ - import 'aos/dist/aos.css';
371
+ + import AOS from 'svg-scroll-draw/aos';
372
+
373
+ AOS.init({ once: true });
374
+ ```
375
+
376
+ No bundler? Swap the script tag, and drop the stylesheet link:
377
+
378
+ ```html
379
+ <script src="https://unpkg.com/svg-scroll-draw/dist/cdn/aos.global.js"></script>
380
+ <script>AOS.init();</script>
381
+ ```
382
+
383
+ `init`, `refresh` and `refreshHard` behave as in AOS 2.3.4: the same trigger positions (anchor
384
+ placements, `data-aos-anchor`, offsets — including AOS's rule that an inline anchor placement without an
385
+ inline offset uses 0), the same `aos-init` / `aos-animate` classes, the same transforms and end states.
386
+ The browser suite runs AOS 2.3.4 and the drop-in side by side on one page in Chromium, Firefox and
387
+ WebKit and fails if any element differs at any scroll stop. AOS 3's `mirror`, `anchorPlacement`,
388
+ `initClassName`, `animatedClassName`, `useClassNames` and the `aos:in` / `aos:out` events work too.
389
+
390
+ Differences, on purpose:
391
+
392
+ - `prefers-reduced-motion: reduce` shows every element in its final state, with no transition.
393
+ - `disable: 'phone' | 'tablet' | 'mobile'` checks the viewport width, not the user agent.
394
+ - Trigger positions are re-measured on `load`, so images that finish late do not shift them.
395
+ - `AOS.destroy()` stops everything, for single-page apps that unmount the page.
396
+ - `throttleDelay` / `debounceDelay` are accepted and ignored: scroll work is batched per frame.
397
+
398
+ ---
399
+
360
400
  ## Instance API
361
401
 
362
402
  Every function returns the same instance object:
@@ -447,6 +487,7 @@ devtools.highlight('#my-element'); // outline for 2 seconds
447
487
  | `svg-scroll-draw/timeline` | `scrollDrawTimeline` |
448
488
  | `svg-scroll-draw/cinematic` | `Cinematic` |
449
489
  | `svg-scroll-draw/devtools` | `devtools` (dev-only) |
490
+ | `svg-scroll-draw/aos` | `AOS` (default), `init`, `refresh`, `refreshHard`, `destroy` |
450
491
 
451
492
  ---
452
493
 
@@ -459,6 +500,7 @@ devtools.highlight('#my-element'); // outline for 2 seconds
459
500
  | `svg-scroll-draw/reveal` | 4.5 KB |
460
501
  | `svg-scroll-draw/text` | 2.5 KB |
461
502
  | `svg-scroll-draw/video` | 2.0 KB |
503
+ | `svg-scroll-draw/aos` (styles included) | 3.0 KB |
462
504
  | `svg-scroll-draw/snap` | 1.7 KB |
463
505
  | `svg-scroll-draw/devtools` | 1.7 KB (dev only) |
464
506
  | `svg-scroll-draw/pin` | 1.6 KB |
@@ -0,0 +1,2 @@
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});function $(){return typeof window>"u"||typeof window.matchMedia!="function"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches}var V=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function M(e,...t){V&&console.warn(`[svg-scroll-draw] ${e}`,...t);}var O={offset:120,delay:0,duration:400,easing:"ease",once:false,mirror:false,anchorPlacement:"top-bottom",disable:false,startEvent:"DOMContentLoaded",disableMutationObserver:false,initClassName:"aos-init",animatedClassName:"aos-animate",useClassNames:false,throttleDelay:99,debounceDelay:50},Y={"ease-in-back":"cubic-bezier(.6,-.28,.735,.045)","ease-out-back":"cubic-bezier(.175,.885,.32,1.275)","ease-in-out-back":"cubic-bezier(.68,-.55,.265,1.55)","ease-in-sine":"cubic-bezier(.47,0,.745,.715)","ease-out-sine":"cubic-bezier(.39,.575,.565,1)","ease-in-out-sine":"cubic-bezier(.445,.05,.55,.95)","ease-in-quad":"cubic-bezier(.55,.085,.68,.53)","ease-out-quad":"cubic-bezier(.25,.46,.45,.94)","ease-in-out-quad":"cubic-bezier(.455,.03,.515,.955)","ease-in-cubic":"cubic-bezier(.55,.055,.675,.19)","ease-out-cubic":"cubic-bezier(.215,.61,.355,1)","ease-in-out-cubic":"cubic-bezier(.645,.045,.355,1)","ease-in-quart":"cubic-bezier(.895,.03,.685,.22)","ease-out-quart":"cubic-bezier(.165,.84,.44,1)","ease-in-out-quart":"cubic-bezier(.77,0,.175,1)"},g="svg-scroll-draw-aos",i=(e,t)=>`translate3d(${e},${t},0)`,B=[["fade-up",i("0","100px")],["fade-down",i("0","-100px")],["fade-right",i("-100px","0")],["fade-left",i("100px","0")],["fade-up-right",i("-100px","100px")],["fade-up-left",i("100px","100px")],["fade-down-right",i("-100px","-100px")],["fade-down-left",i("100px","-100px")],["zoom-in","scale(.6)"],["zoom-out","scale(1.2)"],["zoom-in-up",`${i("0","100px")} scale(.6)`],["zoom-in-down",`${i("0","-100px")} scale(.6)`],["zoom-in-right",`${i("-100px","0")} scale(.6)`],["zoom-in-left",`${i("100px","0")} scale(.6)`],["zoom-out-up",`${i("0","100px")} scale(1.2)`],["zoom-out-down",`${i("0","-100px")} scale(1.2)`],["zoom-out-right",`${i("-100px","0")} scale(1.2)`],["zoom-out-left",`${i("100px","0")} scale(1.2)`],["slide-up",i("0","100%")],["slide-down",i("0","-100%")],["slide-right",i("-100%","0")],["slide-left",i("100%","0")],["flip-left","perspective(2500px) rotateY(-100deg)"],["flip-right","perspective(2500px) rotateY(100deg)"],["flip-up","perspective(2500px) rotateX(-100deg)"],["flip-down","perspective(2500px) rotateX(100deg)"]];function G(e){let t=`.${e}`,n=o=>`[data-aos^=${o}][data-aos^=${o}]`;return ["[data-aos][data-aos]{transition-duration:var(--aos-duration,400ms);transition-timing-function:var(--aos-easing,ease);transition-delay:0s}",`[data-aos][data-aos]${t}{transition-delay:var(--aos-delay,0ms)}`,`${n("fade")}{opacity:0;transition-property:opacity,transform}`,`${n("fade")}${t}{opacity:1;transform:translateZ(0)}`,`${n("zoom")}{opacity:0;transition-property:opacity,transform}`,`${n("zoom")}${t}{opacity:1;transform:translateZ(0) scale(1)}`,`${n("slide")}{transition-property:transform}`,`${n("slide")}${t}{transform:translateZ(0)}`,`${n("flip")}{backface-visibility:hidden;transition-property:transform}`,...B.map(([o,u])=>`[data-aos=${o}]{transform:${u}}`),...["left","right"].map(o=>`[data-aos=flip-${o}]${t}{transform:perspective(2500px) rotateY(0)}`),...["up","down"].map(o=>`[data-aos=flip-${o}]${t}{transform:perspective(2500px) rotateX(0)}`),"[data-aos-instant][data-aos-instant]{transition:none!important}"].join(`
2
+ `)}var a={...O},d=[],m=false,f=0,h,p=null,s=null,w=false,T=()=>typeof window<"u"&&typeof document<"u";function _(e){if(!(e instanceof HTMLElement))return e.getBoundingClientRect().top+window.scrollY;let t=0,n=e;for(;n;)t+=n.offsetTop-(n.tagName!=="BODY"?n.scrollTop:0),n=n.offsetParent;return t}var C=e=>e instanceof HTMLElement?e.offsetHeight:e.getBoundingClientRect().height;function c(e,t){return e.getAttribute(`data-aos-${t}`)}function A(e,t,n){let o=c(e,t);return o==="true"?true:o==="false"?false:n}function N(e,t){let n=c(e,"offset");return n&&!isNaN(Number(n))?parseInt(n,10):n||t?0:a.offset}function W(e){let t=window.innerHeight,n=c(e,"anchor-placement"),o=N(e,n),u=c(e,"anchor"),L=u?document.querySelector(u):null;u&&!L&&M(`aos: data-aos-anchor="${u}" matches nothing; using the element itself`);let x=L||e,l=C(x),r=_(x)-t;switch(n||a.anchorPlacement){case "center-bottom":r+=l/2;break;case "bottom-bottom":r+=l;break;case "top-center":r+=t/2;break;case "center-center":r+=t/2+l/2;break;case "bottom-center":r+=t/2+l;break;case "top-top":r+=t;break;case "bottom-top":r+=t+l;break;case "center-top":r+=t+l/2;break;}return r+o}function X(e){return _(e)+C(e)-N(e,null)}function Z(e){let t=c(e,"duration")??String(a.duration),n=c(e,"delay")??String(a.delay),o=c(e,"easing")??a.easing;e.style.setProperty("--aos-duration",`${parseFloat(t)||0}ms`),e.style.setProperty("--aos-delay",`${parseFloat(n)||0}ms`),e.style.setProperty("--aos-easing",Y[o]??o);}function D(){d=Array.from(document.querySelectorAll("[data-aos]")).map(e=>{let t=d.find(n=>n.node===e);return {node:e,in:0,out:0,once:A(e,"once",a.once),mirror:A(e,"mirror",a.mirror),animated:t?t.animated:e.classList.contains(a.animatedClassName),classes:a.useClassNames?(e.getAttribute("data-aos")||"").split(" ").filter(Boolean):[],id:c(e,"id")}});for(let e of d)Z(e.node),e.node.classList.add(a.initClassName);}function R(){for(let e of d)e.in=W(e.node),e.out=X(e.node);}function H(e,t){document.dispatchEvent(new CustomEvent(`aos:${e}`,{detail:t.node})),t.id&&document.dispatchEvent(new CustomEvent(`aos:${e}:${t.id}`,{detail:t.node}));}function z(e){e.animated||(e.animated=true,e.node.classList.add(a.animatedClassName,...e.classes),H("in",e));}function S(e){e.animated&&(e.animated=false,e.node.classList.remove(a.animatedClassName,...e.classes),H("out",e));}function E(){f=0;let e=window.scrollY;for(let t of d){if(w){z(t);continue}t.mirror&&!t.once&&e>t.out?S(t):e>t.in?z(t):t.once||S(t);}}var k=()=>{f||(f=requestAnimationFrame(E));};function b(){clearTimeout(h),h=setTimeout(v,50);}var q=()=>v();function I(){let e=a.disable;if(typeof e=="function")return e();if(e===true)return true;let t=window.innerWidth;return e==="phone"?t<768:e==="tablet"?t>=768&&t<1024:e==="mobile"?t<1024:false}function P(){document.querySelectorAll("[data-aos]").forEach(e=>{for(let t of ["data-aos","data-aos-easing","data-aos-duration","data-aos-delay"])e.removeAttribute(t);});}function j(){if(document.getElementById(g))return;let e=document.createElement("style");e.id=g,e.textContent=G(a.animatedClassName),document.head.appendChild(e);}function y(){if(!m){if(m=true,s=null,D(),w)for(let e of d)e.node.setAttribute("data-aos-instant","");R(),E(),window.addEventListener("scroll",k,{passive:true}),window.addEventListener("resize",b),window.addEventListener("orientationchange",b),window.addEventListener("load",q),!a.disableMutationObserver&&typeof MutationObserver<"u"&&(p=new MutationObserver(e=>{e.some(n=>[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].some(o=>o instanceof Element&&(o.hasAttribute("data-aos")||o.querySelector("[data-aos]"))))&&Q();}),p.observe(document.documentElement,{childList:true,subtree:true}));}}function U(e={}){if(!T())return [];if((m||s)&&F(),a={...O,...e},I())return P(),[];w=$(),j();let t=document.readyState!=="loading";if(a.startEvent==="DOMContentLoaded"&&t)y();else if(a.startEvent==="load"&&document.readyState==="complete")y();else {let n=a.startEvent==="load"?window:document,o=()=>y();n.addEventListener(a.startEvent,o,{once:true}),s={target:n,type:a.startEvent,fn:o};}return Array.from(document.querySelectorAll("[data-aos]"))}function v(){m&&(R(),E());}function Q(){if(m){if(I()){P();return}D(),v();}}function F(){if(T()){s&&s.target.removeEventListener(s.type,s.fn),s=null,cancelAnimationFrame(f),f=0,clearTimeout(h),window.removeEventListener("scroll",k),window.removeEventListener("resize",b),window.removeEventListener("orientationchange",b),window.removeEventListener("load",q),p?.disconnect(),p=null;for(let e of d)e.node.removeAttribute("data-aos-instant");d=[],m=false,document.getElementById(g)?.remove();}}var J={init:U,refresh:v,refreshHard:Q,destroy:F},oe=J;exports.default=oe;exports.destroy=F;exports.init=U;exports.refresh=v;exports.refreshHard=Q;
@@ -0,0 +1,53 @@
1
+ type AOSAnchorPlacement = 'top-bottom' | 'top-center' | 'top-top' | 'center-bottom' | 'center-center' | 'center-top' | 'bottom-bottom' | 'bottom-center' | 'bottom-top';
2
+ interface AOSOptions {
3
+ /** Px from the trigger point before the animation starts. Default 120. */
4
+ offset?: number;
5
+ /** Ms to wait before animating in. Default 0. */
6
+ delay?: number;
7
+ /** Animation length in ms. Default 400. */
8
+ duration?: number;
9
+ /** An AOS easing name (`'ease-out-back'`…) or any CSS timing function. Default `'ease'`. */
10
+ easing?: string;
11
+ /** Animate only the first time the element scrolls in. Default false. */
12
+ once?: boolean;
13
+ /** Animate out again when the element scrolls past the top. Default false. */
14
+ mirror?: boolean;
15
+ /** Which edge of the element meets which edge of the window. Default `'top-bottom'`. */
16
+ anchorPlacement?: AOSAnchorPlacement;
17
+ /** Skip animations entirely: a boolean, a predicate, or a viewport class. */
18
+ disable?: boolean | 'phone' | 'tablet' | 'mobile' | (() => boolean);
19
+ /** Document event that starts AOS. Default `'DOMContentLoaded'`. */
20
+ startEvent?: string;
21
+ /** Do not watch the DOM for new `[data-aos]` elements. Default false. */
22
+ disableMutationObserver?: boolean;
23
+ /** Class added at init. Default `'aos-init'`. */
24
+ initClassName?: string;
25
+ /** Class added while animated in. Default `'aos-animate'`. */
26
+ animatedClassName?: string;
27
+ /** Also add the `data-aos` value as classes (for animate.css-style sets). Default false. */
28
+ useClassNames?: boolean;
29
+ /** Accepted for compatibility; scroll handling is batched per frame instead. */
30
+ throttleDelay?: number;
31
+ /** Accepted for compatibility; resize handling is debounced internally. */
32
+ debounceDelay?: number;
33
+ }
34
+ /** Start animating every `[data-aos]` element. Same options as AOS. */
35
+ declare function init(options?: AOSOptions): HTMLElement[];
36
+ /** Recalculate every trigger position (after a layout change). */
37
+ declare function refresh(): void;
38
+ /** Find `[data-aos]` elements again (after adding or removing some), then refresh. */
39
+ declare function refreshHard(): void;
40
+ /**
41
+ * Stop listening and remove the injected stylesheet. Not in AOS — added for
42
+ * single-page apps that unmount the page AOS was started on. Elements keep
43
+ * whatever classes they have.
44
+ */
45
+ declare function destroy(): void;
46
+ declare const AOS: {
47
+ init: typeof init;
48
+ refresh: typeof refresh;
49
+ refreshHard: typeof refreshHard;
50
+ destroy: typeof destroy;
51
+ };
52
+
53
+ export { type AOSAnchorPlacement, type AOSOptions, AOS as default, destroy, init, refresh, refreshHard };
@@ -0,0 +1,53 @@
1
+ type AOSAnchorPlacement = 'top-bottom' | 'top-center' | 'top-top' | 'center-bottom' | 'center-center' | 'center-top' | 'bottom-bottom' | 'bottom-center' | 'bottom-top';
2
+ interface AOSOptions {
3
+ /** Px from the trigger point before the animation starts. Default 120. */
4
+ offset?: number;
5
+ /** Ms to wait before animating in. Default 0. */
6
+ delay?: number;
7
+ /** Animation length in ms. Default 400. */
8
+ duration?: number;
9
+ /** An AOS easing name (`'ease-out-back'`…) or any CSS timing function. Default `'ease'`. */
10
+ easing?: string;
11
+ /** Animate only the first time the element scrolls in. Default false. */
12
+ once?: boolean;
13
+ /** Animate out again when the element scrolls past the top. Default false. */
14
+ mirror?: boolean;
15
+ /** Which edge of the element meets which edge of the window. Default `'top-bottom'`. */
16
+ anchorPlacement?: AOSAnchorPlacement;
17
+ /** Skip animations entirely: a boolean, a predicate, or a viewport class. */
18
+ disable?: boolean | 'phone' | 'tablet' | 'mobile' | (() => boolean);
19
+ /** Document event that starts AOS. Default `'DOMContentLoaded'`. */
20
+ startEvent?: string;
21
+ /** Do not watch the DOM for new `[data-aos]` elements. Default false. */
22
+ disableMutationObserver?: boolean;
23
+ /** Class added at init. Default `'aos-init'`. */
24
+ initClassName?: string;
25
+ /** Class added while animated in. Default `'aos-animate'`. */
26
+ animatedClassName?: string;
27
+ /** Also add the `data-aos` value as classes (for animate.css-style sets). Default false. */
28
+ useClassNames?: boolean;
29
+ /** Accepted for compatibility; scroll handling is batched per frame instead. */
30
+ throttleDelay?: number;
31
+ /** Accepted for compatibility; resize handling is debounced internally. */
32
+ debounceDelay?: number;
33
+ }
34
+ /** Start animating every `[data-aos]` element. Same options as AOS. */
35
+ declare function init(options?: AOSOptions): HTMLElement[];
36
+ /** Recalculate every trigger position (after a layout change). */
37
+ declare function refresh(): void;
38
+ /** Find `[data-aos]` elements again (after adding or removing some), then refresh. */
39
+ declare function refreshHard(): void;
40
+ /**
41
+ * Stop listening and remove the injected stylesheet. Not in AOS — added for
42
+ * single-page apps that unmount the page AOS was started on. Elements keep
43
+ * whatever classes they have.
44
+ */
45
+ declare function destroy(): void;
46
+ declare const AOS: {
47
+ init: typeof init;
48
+ refresh: typeof refresh;
49
+ refreshHard: typeof refreshHard;
50
+ destroy: typeof destroy;
51
+ };
52
+
53
+ export { type AOSAnchorPlacement, type AOSOptions, AOS as default, destroy, init, refresh, refreshHard };
@@ -0,0 +1,2 @@
1
+ function $(){return typeof window>"u"||typeof window.matchMedia!="function"?false:window.matchMedia("(prefers-reduced-motion: reduce)").matches}var V=typeof __SVG_SCROLL_DRAW_DEV__<"u"?__SVG_SCROLL_DRAW_DEV__:typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production";function M(e,...t){V&&console.warn(`[svg-scroll-draw] ${e}`,...t);}var O={offset:120,delay:0,duration:400,easing:"ease",once:false,mirror:false,anchorPlacement:"top-bottom",disable:false,startEvent:"DOMContentLoaded",disableMutationObserver:false,initClassName:"aos-init",animatedClassName:"aos-animate",useClassNames:false,throttleDelay:99,debounceDelay:50},Y={"ease-in-back":"cubic-bezier(.6,-.28,.735,.045)","ease-out-back":"cubic-bezier(.175,.885,.32,1.275)","ease-in-out-back":"cubic-bezier(.68,-.55,.265,1.55)","ease-in-sine":"cubic-bezier(.47,0,.745,.715)","ease-out-sine":"cubic-bezier(.39,.575,.565,1)","ease-in-out-sine":"cubic-bezier(.445,.05,.55,.95)","ease-in-quad":"cubic-bezier(.55,.085,.68,.53)","ease-out-quad":"cubic-bezier(.25,.46,.45,.94)","ease-in-out-quad":"cubic-bezier(.455,.03,.515,.955)","ease-in-cubic":"cubic-bezier(.55,.055,.675,.19)","ease-out-cubic":"cubic-bezier(.215,.61,.355,1)","ease-in-out-cubic":"cubic-bezier(.645,.045,.355,1)","ease-in-quart":"cubic-bezier(.895,.03,.685,.22)","ease-out-quart":"cubic-bezier(.165,.84,.44,1)","ease-in-out-quart":"cubic-bezier(.77,0,.175,1)"},g="svg-scroll-draw-aos",i=(e,t)=>`translate3d(${e},${t},0)`,B=[["fade-up",i("0","100px")],["fade-down",i("0","-100px")],["fade-right",i("-100px","0")],["fade-left",i("100px","0")],["fade-up-right",i("-100px","100px")],["fade-up-left",i("100px","100px")],["fade-down-right",i("-100px","-100px")],["fade-down-left",i("100px","-100px")],["zoom-in","scale(.6)"],["zoom-out","scale(1.2)"],["zoom-in-up",`${i("0","100px")} scale(.6)`],["zoom-in-down",`${i("0","-100px")} scale(.6)`],["zoom-in-right",`${i("-100px","0")} scale(.6)`],["zoom-in-left",`${i("100px","0")} scale(.6)`],["zoom-out-up",`${i("0","100px")} scale(1.2)`],["zoom-out-down",`${i("0","-100px")} scale(1.2)`],["zoom-out-right",`${i("-100px","0")} scale(1.2)`],["zoom-out-left",`${i("100px","0")} scale(1.2)`],["slide-up",i("0","100%")],["slide-down",i("0","-100%")],["slide-right",i("-100%","0")],["slide-left",i("100%","0")],["flip-left","perspective(2500px) rotateY(-100deg)"],["flip-right","perspective(2500px) rotateY(100deg)"],["flip-up","perspective(2500px) rotateX(-100deg)"],["flip-down","perspective(2500px) rotateX(100deg)"]];function G(e){let t=`.${e}`,n=o=>`[data-aos^=${o}][data-aos^=${o}]`;return ["[data-aos][data-aos]{transition-duration:var(--aos-duration,400ms);transition-timing-function:var(--aos-easing,ease);transition-delay:0s}",`[data-aos][data-aos]${t}{transition-delay:var(--aos-delay,0ms)}`,`${n("fade")}{opacity:0;transition-property:opacity,transform}`,`${n("fade")}${t}{opacity:1;transform:translateZ(0)}`,`${n("zoom")}{opacity:0;transition-property:opacity,transform}`,`${n("zoom")}${t}{opacity:1;transform:translateZ(0) scale(1)}`,`${n("slide")}{transition-property:transform}`,`${n("slide")}${t}{transform:translateZ(0)}`,`${n("flip")}{backface-visibility:hidden;transition-property:transform}`,...B.map(([o,u])=>`[data-aos=${o}]{transform:${u}}`),...["left","right"].map(o=>`[data-aos=flip-${o}]${t}{transform:perspective(2500px) rotateY(0)}`),...["up","down"].map(o=>`[data-aos=flip-${o}]${t}{transform:perspective(2500px) rotateX(0)}`),"[data-aos-instant][data-aos-instant]{transition:none!important}"].join(`
2
+ `)}var a={...O},d=[],m=false,f=0,h,p=null,s=null,w=false,T=()=>typeof window<"u"&&typeof document<"u";function _(e){if(!(e instanceof HTMLElement))return e.getBoundingClientRect().top+window.scrollY;let t=0,n=e;for(;n;)t+=n.offsetTop-(n.tagName!=="BODY"?n.scrollTop:0),n=n.offsetParent;return t}var C=e=>e instanceof HTMLElement?e.offsetHeight:e.getBoundingClientRect().height;function c(e,t){return e.getAttribute(`data-aos-${t}`)}function A(e,t,n){let o=c(e,t);return o==="true"?true:o==="false"?false:n}function N(e,t){let n=c(e,"offset");return n&&!isNaN(Number(n))?parseInt(n,10):n||t?0:a.offset}function W(e){let t=window.innerHeight,n=c(e,"anchor-placement"),o=N(e,n),u=c(e,"anchor"),L=u?document.querySelector(u):null;u&&!L&&M(`aos: data-aos-anchor="${u}" matches nothing; using the element itself`);let x=L||e,l=C(x),r=_(x)-t;switch(n||a.anchorPlacement){case "center-bottom":r+=l/2;break;case "bottom-bottom":r+=l;break;case "top-center":r+=t/2;break;case "center-center":r+=t/2+l/2;break;case "bottom-center":r+=t/2+l;break;case "top-top":r+=t;break;case "bottom-top":r+=t+l;break;case "center-top":r+=t+l/2;break;}return r+o}function X(e){return _(e)+C(e)-N(e,null)}function Z(e){let t=c(e,"duration")??String(a.duration),n=c(e,"delay")??String(a.delay),o=c(e,"easing")??a.easing;e.style.setProperty("--aos-duration",`${parseFloat(t)||0}ms`),e.style.setProperty("--aos-delay",`${parseFloat(n)||0}ms`),e.style.setProperty("--aos-easing",Y[o]??o);}function D(){d=Array.from(document.querySelectorAll("[data-aos]")).map(e=>{let t=d.find(n=>n.node===e);return {node:e,in:0,out:0,once:A(e,"once",a.once),mirror:A(e,"mirror",a.mirror),animated:t?t.animated:e.classList.contains(a.animatedClassName),classes:a.useClassNames?(e.getAttribute("data-aos")||"").split(" ").filter(Boolean):[],id:c(e,"id")}});for(let e of d)Z(e.node),e.node.classList.add(a.initClassName);}function R(){for(let e of d)e.in=W(e.node),e.out=X(e.node);}function H(e,t){document.dispatchEvent(new CustomEvent(`aos:${e}`,{detail:t.node})),t.id&&document.dispatchEvent(new CustomEvent(`aos:${e}:${t.id}`,{detail:t.node}));}function z(e){e.animated||(e.animated=true,e.node.classList.add(a.animatedClassName,...e.classes),H("in",e));}function S(e){e.animated&&(e.animated=false,e.node.classList.remove(a.animatedClassName,...e.classes),H("out",e));}function E(){f=0;let e=window.scrollY;for(let t of d){if(w){z(t);continue}t.mirror&&!t.once&&e>t.out?S(t):e>t.in?z(t):t.once||S(t);}}var k=()=>{f||(f=requestAnimationFrame(E));};function b(){clearTimeout(h),h=setTimeout(v,50);}var q=()=>v();function I(){let e=a.disable;if(typeof e=="function")return e();if(e===true)return true;let t=window.innerWidth;return e==="phone"?t<768:e==="tablet"?t>=768&&t<1024:e==="mobile"?t<1024:false}function P(){document.querySelectorAll("[data-aos]").forEach(e=>{for(let t of ["data-aos","data-aos-easing","data-aos-duration","data-aos-delay"])e.removeAttribute(t);});}function j(){if(document.getElementById(g))return;let e=document.createElement("style");e.id=g,e.textContent=G(a.animatedClassName),document.head.appendChild(e);}function y(){if(!m){if(m=true,s=null,D(),w)for(let e of d)e.node.setAttribute("data-aos-instant","");R(),E(),window.addEventListener("scroll",k,{passive:true}),window.addEventListener("resize",b),window.addEventListener("orientationchange",b),window.addEventListener("load",q),!a.disableMutationObserver&&typeof MutationObserver<"u"&&(p=new MutationObserver(e=>{e.some(n=>[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].some(o=>o instanceof Element&&(o.hasAttribute("data-aos")||o.querySelector("[data-aos]"))))&&Q();}),p.observe(document.documentElement,{childList:true,subtree:true}));}}function U(e={}){if(!T())return [];if((m||s)&&F(),a={...O,...e},I())return P(),[];w=$(),j();let t=document.readyState!=="loading";if(a.startEvent==="DOMContentLoaded"&&t)y();else if(a.startEvent==="load"&&document.readyState==="complete")y();else {let n=a.startEvent==="load"?window:document,o=()=>y();n.addEventListener(a.startEvent,o,{once:true}),s={target:n,type:a.startEvent,fn:o};}return Array.from(document.querySelectorAll("[data-aos]"))}function v(){m&&(R(),E());}function Q(){if(m){if(I()){P();return}D(),v();}}function F(){if(T()){s&&s.target.removeEventListener(s.type,s.fn),s=null,cancelAnimationFrame(f),f=0,clearTimeout(h),window.removeEventListener("scroll",k),window.removeEventListener("resize",b),window.removeEventListener("orientationchange",b),window.removeEventListener("load",q),p?.disconnect(),p=null;for(let e of d)e.node.removeAttribute("data-aos-instant");d=[],m=false,document.getElementById(g)?.remove();}}var J={init:U,refresh:v,refreshHard:Q,destroy:F},oe=J;export{oe as default,F as destroy,U as init,v as refresh,Q as refreshHard};
@@ -0,0 +1,2 @@
1
+ "use strict";var AOS=(()=>{var y=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var X=(e,t)=>{for(var n in t)y(e,n,{get:t[n],enumerable:!0})},Z=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of G(t))!W.call(e,r)&&r!==n&&y(e,r,{get:()=>t[r],enumerable:!(o=B(t,r))||o.enumerable});return e};var j=e=>Z(y({},"__esModule",{value:!0}),e);var re={};X(re,{default:()=>ie,destroy:()=>$,init:()=>Y,refresh:()=>p,refreshHard:()=>x});function S(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function z(e,...t){}var C={offset:120,delay:0,duration:400,easing:"ease",once:!1,mirror:!1,anchorPlacement:"top-bottom",disable:!1,startEvent:"DOMContentLoaded",disableMutationObserver:!1,initClassName:"aos-init",animatedClassName:"aos-animate",useClassNames:!1,throttleDelay:99,debounceDelay:50},U={"ease-in-back":"cubic-bezier(.6,-.28,.735,.045)","ease-out-back":"cubic-bezier(.175,.885,.32,1.275)","ease-in-out-back":"cubic-bezier(.68,-.55,.265,1.55)","ease-in-sine":"cubic-bezier(.47,0,.745,.715)","ease-out-sine":"cubic-bezier(.39,.575,.565,1)","ease-in-out-sine":"cubic-bezier(.445,.05,.55,.95)","ease-in-quad":"cubic-bezier(.55,.085,.68,.53)","ease-out-quad":"cubic-bezier(.25,.46,.45,.94)","ease-in-out-quad":"cubic-bezier(.455,.03,.515,.955)","ease-in-cubic":"cubic-bezier(.55,.055,.675,.19)","ease-out-cubic":"cubic-bezier(.215,.61,.355,1)","ease-in-out-cubic":"cubic-bezier(.645,.045,.355,1)","ease-in-quart":"cubic-bezier(.895,.03,.685,.22)","ease-out-quart":"cubic-bezier(.165,.84,.44,1)","ease-in-out-quart":"cubic-bezier(.77,0,.175,1)"},h="svg-scroll-draw-aos",i=(e,t)=>`translate3d(${e},${t},0)`,J=[["fade-up",i("0","100px")],["fade-down",i("0","-100px")],["fade-right",i("-100px","0")],["fade-left",i("100px","0")],["fade-up-right",i("-100px","100px")],["fade-up-left",i("100px","100px")],["fade-down-right",i("-100px","-100px")],["fade-down-left",i("100px","-100px")],["zoom-in","scale(.6)"],["zoom-out","scale(1.2)"],["zoom-in-up",`${i("0","100px")} scale(.6)`],["zoom-in-down",`${i("0","-100px")} scale(.6)`],["zoom-in-right",`${i("-100px","0")} scale(.6)`],["zoom-in-left",`${i("100px","0")} scale(.6)`],["zoom-out-up",`${i("0","100px")} scale(1.2)`],["zoom-out-down",`${i("0","-100px")} scale(1.2)`],["zoom-out-right",`${i("-100px","0")} scale(1.2)`],["zoom-out-left",`${i("100px","0")} scale(1.2)`],["slide-up",i("0","100%")],["slide-down",i("0","-100%")],["slide-right",i("-100%","0")],["slide-left",i("100%","0")],["flip-left","perspective(2500px) rotateY(-100deg)"],["flip-right","perspective(2500px) rotateY(100deg)"],["flip-up","perspective(2500px) rotateX(-100deg)"],["flip-down","perspective(2500px) rotateX(100deg)"]];function K(e){let t=`.${e}`,n=o=>`[data-aos^=${o}][data-aos^=${o}]`;return["[data-aos][data-aos]{transition-duration:var(--aos-duration,400ms);transition-timing-function:var(--aos-easing,ease);transition-delay:0s}",`[data-aos][data-aos]${t}{transition-delay:var(--aos-delay,0ms)}`,`${n("fade")}{opacity:0;transition-property:opacity,transform}`,`${n("fade")}${t}{opacity:1;transform:translateZ(0)}`,`${n("zoom")}{opacity:0;transition-property:opacity,transform}`,`${n("zoom")}${t}{opacity:1;transform:translateZ(0) scale(1)}`,`${n("slide")}{transition-property:transform}`,`${n("slide")}${t}{transform:translateZ(0)}`,`${n("flip")}{backface-visibility:hidden;transition-property:transform}`,...J.map(([o,r])=>`[data-aos=${o}]{transform:${r}}`),...["left","right"].map(o=>`[data-aos=flip-${o}]${t}{transform:perspective(2500px) rotateY(0)}`),...["up","down"].map(o=>`[data-aos=flip-${o}]${t}{transform:perspective(2500px) rotateX(0)}`),"[data-aos-instant][data-aos-instant]{transition:none!important}"].join(`
2
+ `)}var a={...C},c=[],m=!1,f=0,E,b=null,d=null,w=!1,D=()=>typeof window<"u"&&typeof document<"u";function N(e){if(!(e instanceof HTMLElement))return e.getBoundingClientRect().top+window.scrollY;let t=0,n=e;for(;n;)t+=n.offsetTop-(n.tagName!=="BODY"?n.scrollTop:0),n=n.offsetParent;return t}var R=e=>e instanceof HTMLElement?e.offsetHeight:e.getBoundingClientRect().height;function u(e,t){return e.getAttribute(`data-aos-${t}`)}function O(e,t,n){let o=u(e,t);return o==="true"?!0:o==="false"?!1:n}function H(e,t){let n=u(e,"offset");return n&&!isNaN(Number(n))?parseInt(n,10):n||t?0:a.offset}function ee(e){let t=window.innerHeight,n=u(e,"anchor-placement"),o=H(e,n),r=u(e,"anchor"),M=r?document.querySelector(r):null;r&&!M&&z(`aos: data-aos-anchor="${r}" matches nothing; using the element itself`);let A=M||e,l=R(A),s=N(A)-t;switch(n||a.anchorPlacement){case"center-bottom":s+=l/2;break;case"bottom-bottom":s+=l;break;case"top-center":s+=t/2;break;case"center-center":s+=t/2+l/2;break;case"bottom-center":s+=t/2+l;break;case"top-top":s+=t;break;case"bottom-top":s+=t+l;break;case"center-top":s+=t+l/2;break;default:break}return s+o}function te(e){return N(e)+R(e)-H(e,null)}function ne(e){let t=u(e,"duration")??String(a.duration),n=u(e,"delay")??String(a.delay),o=u(e,"easing")??a.easing;e.style.setProperty("--aos-duration",`${parseFloat(t)||0}ms`),e.style.setProperty("--aos-delay",`${parseFloat(n)||0}ms`),e.style.setProperty("--aos-easing",U[o]??o)}function k(){c=Array.from(document.querySelectorAll("[data-aos]")).map(e=>{let t=c.find(n=>n.node===e);return{node:e,in:0,out:0,once:O(e,"once",a.once),mirror:O(e,"mirror",a.mirror),animated:t?t.animated:e.classList.contains(a.animatedClassName),classes:a.useClassNames?(e.getAttribute("data-aos")||"").split(" ").filter(Boolean):[],id:u(e,"id")}});for(let e of c)ne(e.node),e.node.classList.add(a.initClassName)}function q(){for(let e of c)e.in=ee(e.node),e.out=te(e.node)}function I(e,t){document.dispatchEvent(new CustomEvent(`aos:${e}`,{detail:t.node})),t.id&&document.dispatchEvent(new CustomEvent(`aos:${e}:${t.id}`,{detail:t.node}))}function T(e){e.animated||(e.animated=!0,e.node.classList.add(a.animatedClassName,...e.classes),I("in",e))}function _(e){e.animated&&(e.animated=!1,e.node.classList.remove(a.animatedClassName,...e.classes),I("out",e))}function L(){f=0;let e=window.scrollY;for(let t of c){if(w){T(t);continue}t.mirror&&!t.once&&e>t.out?_(t):e>t.in?T(t):t.once||_(t)}}var P=()=>{f||(f=requestAnimationFrame(L))};function v(){clearTimeout(E),E=setTimeout(p,50)}var Q=()=>p();function V(){let e=a.disable;if(typeof e=="function")return e();if(e===!0)return!0;let t=window.innerWidth;return e==="phone"?t<768:e==="tablet"?t>=768&&t<1024:e==="mobile"?t<1024:!1}function F(){document.querySelectorAll("[data-aos]").forEach(e=>{for(let t of["data-aos","data-aos-easing","data-aos-duration","data-aos-delay"])e.removeAttribute(t)})}function oe(){if(document.getElementById(h))return;let e=document.createElement("style");e.id=h,e.textContent=K(a.animatedClassName),document.head.appendChild(e)}function g(){if(!m){if(m=!0,d=null,k(),w)for(let e of c)e.node.setAttribute("data-aos-instant","");q(),L(),window.addEventListener("scroll",P,{passive:!0}),window.addEventListener("resize",v),window.addEventListener("orientationchange",v),window.addEventListener("load",Q),!a.disableMutationObserver&&typeof MutationObserver<"u"&&(b=new MutationObserver(e=>{e.some(n=>[...Array.from(n.addedNodes),...Array.from(n.removedNodes)].some(o=>o instanceof Element&&(o.hasAttribute("data-aos")||o.querySelector("[data-aos]"))))&&x()}),b.observe(document.documentElement,{childList:!0,subtree:!0}))}}function Y(e={}){if(!D())return[];if((m||d)&&$(),a={...C,...e},V())return F(),[];w=S(),oe();let t=document.readyState!=="loading";if(a.startEvent==="DOMContentLoaded"&&t)g();else if(a.startEvent==="load"&&document.readyState==="complete")g();else{let n=a.startEvent==="load"?window:document,o=()=>g();n.addEventListener(a.startEvent,o,{once:!0}),d={target:n,type:a.startEvent,fn:o}}return Array.from(document.querySelectorAll("[data-aos]"))}function p(){m&&(q(),L())}function x(){if(m){if(V()){F();return}k(),p()}}function $(){if(D()){d&&d.target.removeEventListener(d.type,d.fn),d=null,cancelAnimationFrame(f),f=0,clearTimeout(E),window.removeEventListener("scroll",P),window.removeEventListener("resize",v),window.removeEventListener("orientationchange",v),window.removeEventListener("load",Q),b?.disconnect(),b=null;for(let e of c)e.node.removeAttribute("data-aos-instant");c=[],m=!1,document.getElementById(h)?.remove()}}var ae={init:Y,refresh:p,refreshHard:x,destroy:$},ie=ae;return j(re);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svg-scroll-draw",
3
- "version": "2.10.2",
3
+ "version": "2.11.0",
4
4
  "description": "Scroll-driven animation for the web — draw SVG paths, reveal elements, pin sections, scrub video. Zero dependencies, native CSS fast path, works with React, Vue, Svelte, Solid, Angular, Astro and vanilla JS",
5
5
  "keywords": [
6
6
  "svg",
@@ -56,7 +56,10 @@
56
56
  "animation-timeline",
57
57
  "view-timeline",
58
58
  "scroll-timeline",
59
- "typescript"
59
+ "typescript",
60
+ "aos",
61
+ "animate-on-scroll",
62
+ "data-aos"
60
63
  ],
61
64
  "homepage": "https://svg-scroll-draw.vercel.app",
62
65
  "repository": {
@@ -139,6 +142,9 @@
139
142
  ],
140
143
  "horizontal": [
141
144
  "./dist/horizontal/index.d.ts"
145
+ ],
146
+ "aos": [
147
+ "./dist/aos/index.d.ts"
142
148
  ]
143
149
  }
144
150
  },
@@ -358,6 +364,16 @@
358
364
  "default": "./dist/horizontal/index.cjs"
359
365
  }
360
366
  },
367
+ "./aos": {
368
+ "import": {
369
+ "types": "./dist/aos/index.d.mts",
370
+ "default": "./dist/aos/index.mjs"
371
+ },
372
+ "require": {
373
+ "types": "./dist/aos/index.d.ts",
374
+ "default": "./dist/aos/index.cjs"
375
+ }
376
+ },
361
377
  "./package.json": "./package.json"
362
378
  },
363
379
  "scripts": {