@ssgoi/core 0.0.3 → 2.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.
Files changed (58) hide show
  1. package/README.md +252 -23
  2. package/dist/animator.d.ts +28 -17
  3. package/dist/animator.d.ts.map +1 -1
  4. package/dist/create-ssgoi-transition-context.d.ts.map +1 -1
  5. package/dist/create-transition-callback.d.ts +3 -32
  6. package/dist/create-transition-callback.d.ts.map +1 -1
  7. package/dist/index.cjs +1 -1
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +374 -213
  11. package/dist/presets/index.cjs +1 -0
  12. package/dist/presets/index.d.ts +16 -0
  13. package/dist/presets/index.d.ts.map +1 -0
  14. package/dist/presets/index.js +35 -0
  15. package/dist/transition-strategy.d.ts +60 -0
  16. package/dist/transition-strategy.d.ts.map +1 -0
  17. package/dist/transition.d.ts +55 -11
  18. package/dist/transition.d.ts.map +1 -1
  19. package/dist/transitions/blur.d.ts +5 -1
  20. package/dist/transitions/blur.d.ts.map +1 -1
  21. package/dist/transitions/bounce.d.ts +5 -0
  22. package/dist/transitions/bounce.d.ts.map +1 -1
  23. package/dist/transitions/fade.d.ts +3 -0
  24. package/dist/transitions/fade.d.ts.map +1 -1
  25. package/dist/transitions/fly.d.ts +30 -0
  26. package/dist/transitions/fly.d.ts.map +1 -0
  27. package/dist/transitions/index.cjs +1 -1
  28. package/dist/transitions/index.d.ts +1 -0
  29. package/dist/transitions/index.d.ts.map +1 -1
  30. package/dist/transitions/index.js +200 -120
  31. package/dist/transitions/none.d.ts +3 -0
  32. package/dist/transitions/none.d.ts.map +1 -1
  33. package/dist/transitions/rotate.d.ts +6 -0
  34. package/dist/transitions/rotate.d.ts.map +1 -1
  35. package/dist/transitions/scale.d.ts +6 -3
  36. package/dist/transitions/scale.d.ts.map +1 -1
  37. package/dist/transitions/slide.d.ts +6 -1
  38. package/dist/transitions/slide.d.ts.map +1 -1
  39. package/dist/types.d.ts +19 -7
  40. package/dist/types.d.ts.map +1 -1
  41. package/dist/utils-8Eptbv7c.cjs +2 -0
  42. package/dist/utils-DTRMUQW4.js +31 -0
  43. package/dist/utils.d.ts +11 -0
  44. package/dist/utils.d.ts.map +1 -1
  45. package/dist/view-transitions/drill.d.ts +9 -0
  46. package/dist/view-transitions/drill.d.ts.map +1 -0
  47. package/dist/view-transitions/fade.d.ts +3 -1
  48. package/dist/view-transitions/fade.d.ts.map +1 -1
  49. package/dist/view-transitions/hero.d.ts.map +1 -1
  50. package/dist/view-transitions/index.cjs +1 -1
  51. package/dist/view-transitions/index.d.ts +2 -1
  52. package/dist/view-transitions/index.d.ts.map +1 -1
  53. package/dist/view-transitions/index.js +233 -177
  54. package/dist/view-transitions/scroll.d.ts +8 -0
  55. package/dist/view-transitions/scroll.d.ts.map +1 -0
  56. package/package.json +28 -10
  57. package/dist/utils-BSgyev81.cjs +0 -1
  58. package/dist/utils-DR41YsAh.js +0 -16
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../utils-BSgyev81.cjs"),C=(t={})=>{var e,i;const n={stiffness:((e=t.spring)==null?void 0:e.stiffness)??300,damping:((i=t.spring)==null?void 0:i.damping)??30};return{in:s=>({spring:n,tick:l=>{s.style.opacity=l.toString()}}),out:s=>({spring:n,tick:l=>{s.style.opacity=l.toString()},prepare:k.prepareOutgoing})}};function E(t,n){return t.querySelector(`[data-hero-key="${n}"]`)}function A(t,n){const e=t.getBoundingClientRect(),i=n.getBoundingClientRect();return new DOMRect(i.left-e.left,i.top-e.top,i.width,i.height)}const D=(t={})=>{var l,r;const n={stiffness:((l=t.spring)==null?void 0:l.stiffness)??300,damping:((r=t.spring)==null?void 0:r.damping)??30},e=t.timeout??300;let i=null,s=null;return{in:async(c,o)=>{const h=c,g=Array.from(h.querySelectorAll("[data-hero-key]"));if(g.length===0)return{spring:n,tick:()=>{}};if(!await new Promise(a=>{i?a(!0):(s=a,setTimeout(()=>{s=null,a(!1)},e))})||!i)return i=null,{spring:n,tick:()=>{}};const p=g.map(a=>{const f=a.getAttribute("data-hero-key");if(!f)return null;const u=E(i,f);if(!u)return null;const d=a,$=A(i,u),w=A(h,d),x=$.left-w.left-o.scrollOffset.x,M=$.top-w.top-o.scrollOffset.y,q=$.width/w.width,O=$.height/w.height,T=d.style.transform,P=d.style.position,b=d.style.transformOrigin;return{toEl:d,dx:x,dy:M,dw:q,dh:O,originalTransform:T,originalPosition:P,originalTransformOrigin:b}}).filter(Boolean);return i=null,p.length===0?{spring:n,tick:()=>{}}:{spring:n,prepare:()=>{p.forEach(({toEl:a})=>{a.style.position="relative",a.style.transformOrigin="top left"})},tick:a=>{p.forEach(({toEl:f,dx:u,dy:d,dw:$,dh:w})=>{f.style.transform=`translate(${(1-a)*u}px,${(1-a)*d}px) scale(${a+(1-a)*$}, ${a+(1-a)*w})`})},onEnd:()=>{p.forEach(({toEl:a,originalTransform:f,originalPosition:u,originalTransformOrigin:d})=>{a.style.transform=f,a.style.position=u,a.style.transformOrigin=d})}}},out:async c=>({onStart:()=>{i=c,s&&(s(!0),s=null)},prepare:o=>{k.prepareOutgoing(o),o.style.opacity="0"}})}};function S(t,n){const e=t.getBoundingClientRect(),i=n.getBoundingClientRect();return new DOMRect(i.left-e.left,i.top-e.top,i.width,i.height)}function H({detailRect:t,galleryRect:n,pageRect:e,scrollOffset:i},s){const l=n.left-t.left+(n.width-t.width)/2-i.x,r=n.top-t.top+(n.height-t.height)/2-i.y,c=n.width/t.width,o=n.height/t.height,h=Math.max(c,o),g=t.top/e.height*100,y=(e.width-(t.left+t.width))/e.width*100,p=(e.height-(t.top+t.height))/e.height*100,a=t.left/e.width*100;return s.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,f=>{const u=1-f,d=g*u,$=y*u,w=p*u,x=a*u;s.style.clipPath=`inset(${d}% ${$}% ${w}% ${x}%)`,s.style.transform=`translate(${l*u}px, ${r*u}px) scale(${1+(h-1)*u})`}}function F({galleryRect:t,detailRect:n,scrollOffset:e},i){const s=n.left-t.left+(n.width-t.width)/2+e.x,l=n.top-t.top+(n.height-t.height)/2+e.y,r=n.width/t.width,c=n.height/t.height,o=Math.max(r,c);return h=>{i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`;const g=1-h;i.style.transform=`translate(${s*g-e.x}px, ${l*g-e.y}px) scale(${1+(o-1)*g})`,i.style.opacity=`${1-g}`}}function I({galleryRect:t,detailRect:n,scrollOffset:e},i){const s=n.left-t.left+(n.width-t.width)/2-e.x,l=n.top-t.top+(n.height-t.height)/2-e.y,r=n.width/t.width,c=n.height/t.height,o=Math.max(r,c);return h=>{const g=1-h,y=h;i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,i.style.transform=`translate(${s*g}px, ${l*g}px) scale(${1+(o-1)*g})`,i.style.opacity=`${y}`}}function L({detailRect:t,galleryRect:n,pageRect:e,scrollOffset:i},s){const l=n.left-t.left+(n.width-t.width)/2+i.x,r=n.top-t.top+(n.height-t.height)/2+i.y,c=n.width/t.width,o=n.height/t.height,h=Math.min(c,o),g=t.top/e.height*100,y=(e.width-(t.left+t.width))/e.width*100,p=(e.height-(t.top+t.height))/e.height*100,a=t.left/e.width*100;return s.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,f=>{const u=1-f,d=g*u,$=y*u,w=p*u,x=a*u;s.style.clipPath=`inset(${d}% ${$}% ${w}% ${x}%)`,s.style.transform=`translate(${l*u-i.x}px, ${r*u-i.y}px) scale(${1+(h-1)*u})`}}function X(t,n,e){const i=t.querySelector("[data-pinterest-detail-key]"),s=n.querySelector("[data-pinterest-detail-key]");if(t.querySelectorAll("[data-pinterest-detail-key]").length>1||n.querySelectorAll("[data-pinterest-detail-key]").length>1)return null;let l=null,r=null,c=!1;if(!i&&s){r=s;const y=r.getAttribute("data-pinterest-detail-key");if(!y)return null;l=t.querySelector(`[data-pinterest-gallery-key="${y}"]`),l&&(c=!0)}else if(i&&!s){r=i;const y=r.getAttribute("data-pinterest-detail-key");if(!y)return null;l=n.querySelector(`[data-pinterest-gallery-key="${y}"]`),l&&(c=!1)}if(!l||!r)return null;const o=S(c?t:n,l),h=S(c?n:t,r),g=n.getBoundingClientRect();return c?{inAnimation:H({detailRect:h,galleryRect:o,pageRect:g,scrollOffset:e},n),outAnimation:F({galleryRect:o,detailRect:h,scrollOffset:e},t)}:{inAnimation:I({galleryRect:o,detailRect:h,scrollOffset:e},n),outAnimation:L({detailRect:h,galleryRect:o,pageRect:g,scrollOffset:e},t)}}const Y=(t={})=>{var r,c;const n={stiffness:((r=t.spring)==null?void 0:r.stiffness)??50,damping:((c=t.spring)==null?void 0:c.damping)??10},e=t.timeout??300;let i=null,s=null,l=null;return{in:async(o,{scrollOffset:h})=>{const g=o;return!await new Promise(p=>{i?p(!0):(s=p,setTimeout(()=>{s=null,p(!1)},e))})||!i?(i=null,{spring:n,tick:()=>{}}):(l=X(i,g,h),l?(i=null,{spring:n,tick:p=>{l&&l.inAnimation(p)}}):{spring:n,tick:()=>{}})},out:async o=>({spring:n,onStart:()=>{i=o,s&&(s(!0),s=null)},prepare:h=>{k.prepareOutgoing(h),h.style.zIndex="-1"},tick:h=>{l&&l.outAnimation(h)}})}};function B(t){const n=t.getBoundingClientRect(),e=t.clientHeight,s=50*(window.innerHeight-n.top)/e;return Math.min(Math.max(s,0),100)}const m=(t={})=>{var e,i;const n={stiffness:((e=t.spring)==null?void 0:e.stiffness)??300,damping:((i=t.spring)==null?void 0:i.damping)??200};return{in:s=>{const l=B(s);return{spring:n,tick:r=>{s.style.clipPath=`circle(${r*100}% at 50% ${l}%)`}}},out:s=>{const l=B(s);return{spring:n,tick:r=>{s.style.clipPath=`circle(${r*100}% at 50% ${l}%)`,s.style.zIndex="100"},prepare:k.prepareOutgoing}}}};exports.fade=C;exports.hero=D;exports.pinterest=Y;exports.ripple=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("../utils-8Eptbv7c.cjs"),q=(t={})=>{var a,l;const{opacity:n=!1,direction:s="enter"}=t,e={stiffness:((a=t.spring)==null?void 0:a.stiffness)??150,damping:((l=t.spring)==null?void 0:l.damping)??20};return s==="enter"?{in:r=>({spring:e,tick:i=>{r.style.transform=`translateX(${(1-i)*100}%)`,n&&(r.style.opacity=i.toString())}}),out:r=>({spring:e,prepare:i=>{x.prepareOutgoing(i),i.style.zIndex="-1"},tick:i=>{r.style.transform=`translateX(${-(1-i)*20}%)`,n&&(r.style.opacity=i.toString())}})}:{in:r=>({spring:{stiffness:100,damping:20},tick:i=>{r.style.transform=`translateX(${-(1-i)*20}%)`,n&&(r.style.opacity=i.toString())}}),out:r=>({spring:{stiffness:100,damping:20},prepare:i=>{x.prepareOutgoing(i),i.style.zIndex="100"},tick:i=>{r.style.transform=`translateX(${(1-i)*100}%)`,n&&(r.style.opacity=i.toString())}})}},L={stiffness:400,damping:20},Y={stiffness:40,damping:8},F=100,M=(t={})=>{const{inSpring:n=Y,outSpring:s=L,transitionDelay:e=F}=t;let a,l=null;return{in:r=>({spring:n,prepare:i=>{i.style.opacity="0"},wait:async()=>{a&&(await a,await x.sleep(e))},tick:i=>{r.style.opacity=i.toString()}}),out:r=>(a=new Promise(i=>{l=i}),{spring:s,tick:i=>{r.style.opacity=i.toString()},prepare:x.prepareOutgoing,onEnd:()=>{l&&l()}})}};function X(t,n){return t.querySelector(`[data-hero-key="${n}"]`)}function S(t,n){const s=t.getBoundingClientRect(),e=n.getBoundingClientRect();return new DOMRect(e.left-s.left,e.top-s.top,e.width,e.height)}const z=(t={})=>{var l,r;const n={stiffness:((l=t.spring)==null?void 0:l.stiffness)??300,damping:((r=t.spring)==null?void 0:r.damping)??30},s=t.timeout??300;let e=null,a=null;return{in:async(i,o)=>{const u=i,p=Array.from(u.querySelectorAll("[data-hero-key]"));if(p.length===0)return{spring:n,tick:()=>{}};if(!await new Promise(h=>{e?h(!0):(a=h,setTimeout(()=>{a=null,h(!1)},s))})||!e)return e=null,{spring:n,tick:()=>{}};const g=p.map(h=>{const $=h.getAttribute("data-hero-key");if(!$)return null;const c=X(e,$);if(!c)return null;const y=h,f=S(e,c),w=S(u,y),k=f.left-w.left-o.scrollOffset.x,T=f.top-w.top-o.scrollOffset.y,m=f.width/w.width,O=f.height/w.height,D=y.style.transform,E=y.style.position,B=y.style.transformOrigin,P=y.style.zIndex;return{toEl:y,dx:k,dy:T,dw:m,dh:O,originalTransform:D,originalPosition:E,originalTransformOrigin:B,originalZIndex:P}}).filter(Boolean);return e=null,g.length===0?{spring:n,tick:()=>{}}:{spring:n,prepare:()=>{g.forEach(({toEl:h})=>{h.style.position="relative",h.style.transformOrigin="top left",h.style.zIndex="1000"})},tick:h=>{g.forEach(({toEl:$,dx:c,dy:y,dw:f,dh:w})=>{$.style.transform=`translate(${(1-h)*c}px,${(1-h)*y}px) scale(${h+(1-h)*f}, ${h+(1-h)*w})`})},onEnd:()=>{g.forEach(({toEl:h,originalTransform:$,originalPosition:c,originalTransformOrigin:y,originalZIndex:f})=>{h.style.transform=$,h.style.position=c,h.style.transformOrigin=y,h.style.zIndex=f})}}},out:async i=>({onStart:()=>{e=i,a&&(a(!0),a=null)},prepare:o=>{x.prepareOutgoing(o),o.style.opacity="0"}})}};function A(t,n){const s=t.getBoundingClientRect(),e=n.getBoundingClientRect();return new DOMRect(e.left-s.left,e.top-s.top,e.width,e.height)}function C({detailRect:t,galleryRect:n,pageRect:s,scrollOffset:e},a){const l=n.left-t.left+(n.width-t.width)/2-e.x,r=n.top-t.top+(n.height-t.height)/2-e.y,i=n.width/t.width,o=n.height/t.height,u=Math.max(i,o),p=t.top/s.height*100,d=(s.width-(t.left+t.width))/s.width*100,g=(s.height-(t.top+t.height))/s.height*100,h=t.left/s.width*100;return a.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,$=>{const c=1-$,y=p*c,f=d*c,w=g*c,k=h*c;a.style.clipPath=`inset(${y}% ${f}% ${w}% ${k}%)`,a.style.transform=`translate(${l*c}px, ${r*c}px) scale(${1+(u-1)*c})`}}function _({galleryRect:t,detailRect:n,scrollOffset:s},e){const a=n.left-t.left+(n.width-t.width)/2+s.x,l=n.top-t.top+(n.height-t.height)/2+s.y,r=n.width/t.width,i=n.height/t.height,o=Math.max(r,i);return u=>{e.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`;const p=1-u;e.style.transform=`translate(${a*p-s.x}px, ${l*p-s.y}px) scale(${1+(o-1)*p})`,e.style.opacity=`${1-p}`}}function U({galleryRect:t,detailRect:n,scrollOffset:s},e){const a=n.left-t.left+(n.width-t.width)/2-s.x,l=n.top-t.top+(n.height-t.height)/2-s.y,r=n.width/t.width,i=n.height/t.height,o=Math.max(r,i);return u=>{const p=1-u,d=u;e.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,e.style.transform=`translate(${a*p}px, ${l*p}px) scale(${1+(o-1)*p})`,e.style.opacity=`${d}`}}function b({detailRect:t,galleryRect:n,pageRect:s,scrollOffset:e},a){const l=n.left-t.left+(n.width-t.width)/2+e.x,r=n.top-t.top+(n.height-t.height)/2+e.y,i=n.width/t.width,o=n.height/t.height,u=Math.min(i,o),p=t.top/s.height*100,d=(s.width-(t.left+t.width))/s.width*100,g=(s.height-(t.top+t.height))/s.height*100,h=t.left/s.width*100;return a.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,$=>{const c=1-$,y=p*c,f=d*c,w=g*c,k=h*c;a.style.clipPath=`inset(${y}% ${f}% ${w}% ${k}%)`,a.style.transform=`translate(${l*c-e.x}px, ${r*c-e.y}px) scale(${1+(u-1)*c})`}}function G(t,n,s){const e=t.querySelector("[data-pinterest-detail-key]"),a=n.querySelector("[data-pinterest-detail-key]");if(t.querySelectorAll("[data-pinterest-detail-key]").length>1||n.querySelectorAll("[data-pinterest-detail-key]").length>1)return null;let l=null,r=null,i=!1;if(!e&&a){r=a;const d=r.getAttribute("data-pinterest-detail-key");if(!d)return null;l=t.querySelector(`[data-pinterest-gallery-key="${d}"]`),l&&(i=!0)}else if(e&&!a){r=e;const d=r.getAttribute("data-pinterest-detail-key");if(!d)return null;l=n.querySelector(`[data-pinterest-gallery-key="${d}"]`),l&&(i=!1)}if(!l||!r)return null;const o=A(i?t:n,l),u=A(i?n:t,r),p=n.getBoundingClientRect();return i?{inAnimation:C({detailRect:u,galleryRect:o,pageRect:p,scrollOffset:s},n),outAnimation:_({galleryRect:o,detailRect:u,scrollOffset:s},t)}:{inAnimation:U({galleryRect:o,detailRect:u,scrollOffset:s},n),outAnimation:b({detailRect:u,galleryRect:o,pageRect:p,scrollOffset:s},t)}}const v=(t={})=>{var r,i;const n={stiffness:((r=t.spring)==null?void 0:r.stiffness)??50,damping:((i=t.spring)==null?void 0:i.damping)??10},s=t.timeout??300;let e=null,a=null,l=null;return{in:async(o,{scrollOffset:u})=>{const p=o;return!await new Promise(g=>{e?g(!0):(a=g,setTimeout(()=>{a=null,g(!1)},s))})||!e?(e=null,{spring:n,tick:()=>{}}):(l=G(e,p,u),l?(e=null,{spring:n,tick:g=>{l&&l.inAnimation(g)}}):{spring:n,tick:()=>{}})},out:async o=>({spring:n,onStart:()=>{e=o,a&&(a(!0),a=null)},prepare:u=>{x.prepareOutgoing(u),u.style.zIndex="-1"},tick:u=>{l&&l.outAnimation(u)}})}},I={stiffness:30,damping:7},j=(t={})=>{var a,l;const n=t.direction??"up",s={stiffness:((a=t.spring)==null?void 0:a.stiffness)??I.stiffness,damping:((l=t.spring)==null?void 0:l.damping)??I.damping},e=n==="up";return{in:r=>({spring:s,tick:i=>{const o=e?(1-i)*100:(1-i)*-100;r.style.transform=`translateY(${o}vh)`}}),out:r=>({spring:s,tick:i=>{const o=e?(1-i)*-100:(1-i)*100;r.style.transform=`translateY(${o}vh)`},prepare:i=>{x.prepareOutgoing(i),i.style.zIndex=e?"-1":"1"}})}};exports.drill=q;exports.fade=M;exports.hero=z;exports.pinterest=v;exports.scroll=j;
@@ -1,5 +1,6 @@
1
+ export * from './drill';
1
2
  export * from './fade';
2
3
  export * from './hero';
3
4
  export * from './pinterest';
4
- export * from './ripple';
5
+ export * from './scroll';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/view-transitions/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/view-transitions/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC"}
@@ -1,84 +1,142 @@
1
- import { p as k } from "../utils-DR41YsAh.js";
2
- const X = (t = {}) => {
3
- var e, i;
4
- const n = {
5
- stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 300,
6
- damping: ((i = t.spring) == null ? void 0 : i.damping) ?? 30
1
+ import { a as x, s as Y } from "../utils-DTRMUQW4.js";
2
+ const b = (t = {}) => {
3
+ var l, r;
4
+ const { opacity: n = !1, direction: s = "enter" } = t, e = {
5
+ stiffness: ((l = t.spring) == null ? void 0 : l.stiffness) ?? 150,
6
+ damping: ((r = t.spring) == null ? void 0 : r.damping) ?? 20
7
7
  };
8
+ return s === "enter" ? {
9
+ in: (a) => ({
10
+ spring: e,
11
+ tick: (i) => {
12
+ a.style.transform = `translateX(${(1 - i) * 100}%)`, n && (a.style.opacity = i.toString());
13
+ }
14
+ }),
15
+ out: (a) => ({
16
+ spring: e,
17
+ prepare: (i) => {
18
+ x(i), i.style.zIndex = "-1";
19
+ },
20
+ tick: (i) => {
21
+ a.style.transform = `translateX(${-(1 - i) * 20}%)`, n && (a.style.opacity = i.toString());
22
+ }
23
+ })
24
+ } : {
25
+ in: (a) => ({
26
+ spring: {
27
+ stiffness: 100,
28
+ damping: 20
29
+ },
30
+ tick: (i) => {
31
+ a.style.transform = `translateX(${-(1 - i) * 20}%)`, n && (a.style.opacity = i.toString());
32
+ }
33
+ }),
34
+ out: (a) => ({
35
+ spring: {
36
+ stiffness: 100,
37
+ damping: 20
38
+ },
39
+ prepare: (i) => {
40
+ x(i), i.style.zIndex = "100";
41
+ },
42
+ tick: (i) => {
43
+ a.style.transform = `translateX(${(1 - i) * 100}%)`, n && (a.style.opacity = i.toString());
44
+ }
45
+ })
46
+ };
47
+ }, q = { stiffness: 400, damping: 20 }, F = { stiffness: 40, damping: 8 }, X = 100, v = (t = {}) => {
48
+ const {
49
+ inSpring: n = F,
50
+ outSpring: s = q,
51
+ transitionDelay: e = X
52
+ } = t;
53
+ let l, r = null;
8
54
  return {
9
- in: (s) => ({
55
+ in: (a) => ({
10
56
  spring: n,
11
- tick: (l) => {
12
- s.style.opacity = l.toString();
57
+ prepare: (i) => {
58
+ i.style.opacity = "0";
59
+ },
60
+ wait: async () => {
61
+ l && (await l, await Y(e));
62
+ },
63
+ tick: (i) => {
64
+ a.style.opacity = i.toString();
13
65
  }
14
66
  }),
15
- out: (s) => ({
16
- spring: n,
17
- tick: (l) => {
18
- s.style.opacity = l.toString();
67
+ out: (a) => (l = new Promise((i) => {
68
+ r = i;
69
+ }), {
70
+ spring: s,
71
+ tick: (i) => {
72
+ a.style.opacity = i.toString();
19
73
  },
20
- prepare: k
74
+ prepare: x,
75
+ onEnd: () => {
76
+ r && r();
77
+ }
21
78
  })
22
79
  };
23
80
  };
24
- function D(t, n) {
81
+ function z(t, n) {
25
82
  return t.querySelector(`[data-hero-key="${n}"]`);
26
83
  }
27
84
  function A(t, n) {
28
- const e = t.getBoundingClientRect(), i = n.getBoundingClientRect();
85
+ const s = t.getBoundingClientRect(), e = n.getBoundingClientRect();
29
86
  return new DOMRect(
30
- i.left - e.left,
31
- i.top - e.top,
32
- i.width,
33
- i.height
87
+ e.left - s.left,
88
+ e.top - s.top,
89
+ e.width,
90
+ e.height
34
91
  );
35
92
  }
36
- const Y = (t = {}) => {
37
- var l, r;
93
+ const H = (t = {}) => {
94
+ var r, a;
38
95
  const n = {
39
- stiffness: ((l = t.spring) == null ? void 0 : l.stiffness) ?? 300,
40
- damping: ((r = t.spring) == null ? void 0 : r.damping) ?? 30
41
- }, e = t.timeout ?? 300;
42
- let i = null, s = null;
96
+ stiffness: ((r = t.spring) == null ? void 0 : r.stiffness) ?? 300,
97
+ damping: ((a = t.spring) == null ? void 0 : a.damping) ?? 30
98
+ }, s = t.timeout ?? 300;
99
+ let e = null, l = null;
43
100
  return {
44
- in: async (c, o) => {
45
- const h = c, g = Array.from(h.querySelectorAll("[data-hero-key]"));
46
- if (g.length === 0)
101
+ in: async (i, o) => {
102
+ const c = i, y = Array.from(c.querySelectorAll("[data-hero-key]"));
103
+ if (y.length === 0)
47
104
  return {
48
105
  spring: n,
49
106
  tick: () => {
50
107
  }
51
108
  // No hero elements, skip animation
52
109
  };
53
- if (!await new Promise((a) => {
54
- i ? a(!0) : (s = a, setTimeout(() => {
55
- s = null, a(!1);
56
- }, e));
57
- }) || !i)
58
- return i = null, {
110
+ if (!await new Promise((h) => {
111
+ e ? h(!0) : (l = h, setTimeout(() => {
112
+ l = null, h(!1);
113
+ }, s));
114
+ }) || !e)
115
+ return e = null, {
59
116
  spring: n,
60
117
  tick: () => {
61
118
  }
62
119
  // No fromNode, skip animation
63
120
  };
64
- const p = g.map((a) => {
65
- const f = a.getAttribute("data-hero-key");
66
- if (!f) return null;
67
- const u = D(i, f);
121
+ const p = y.map((h) => {
122
+ const $ = h.getAttribute("data-hero-key");
123
+ if (!$) return null;
124
+ const u = z(e, $);
68
125
  if (!u) return null;
69
- const d = a, $ = A(i, u), w = A(h, d), x = $.left - w.left - o.scrollOffset.x, M = $.top - w.top - o.scrollOffset.y, q = $.width / w.width, T = $.height / w.height, C = d.style.transform, E = d.style.position, P = d.style.transformOrigin;
126
+ const g = h, f = A(e, u), w = A(c, g), k = f.left - w.left - o.scrollOffset.x, T = f.top - w.top - o.scrollOffset.y, m = f.width / w.width, D = f.height / w.height, E = g.style.transform, B = g.style.position, L = g.style.transformOrigin, P = g.style.zIndex;
70
127
  return {
71
- toEl: d,
72
- dx: x,
73
- dy: M,
74
- dw: q,
75
- dh: T,
76
- originalTransform: C,
77
- originalPosition: E,
78
- originalTransformOrigin: P
128
+ toEl: g,
129
+ dx: k,
130
+ dy: T,
131
+ dw: m,
132
+ dh: D,
133
+ originalTransform: E,
134
+ originalPosition: B,
135
+ originalTransformOrigin: L,
136
+ originalZIndex: P
79
137
  };
80
138
  }).filter(Boolean);
81
- return i = null, p.length === 0 ? {
139
+ return e = null, p.length === 0 ? {
82
140
  spring: n,
83
141
  tick: () => {
84
142
  }
@@ -86,164 +144,165 @@ const Y = (t = {}) => {
86
144
  } : {
87
145
  spring: n,
88
146
  prepare: () => {
89
- p.forEach(({ toEl: a }) => {
90
- a.style.position = "relative", a.style.transformOrigin = "top left";
147
+ p.forEach(({ toEl: h }) => {
148
+ h.style.position = "relative", h.style.transformOrigin = "top left", h.style.zIndex = "1000";
91
149
  });
92
150
  },
93
- tick: (a) => {
94
- p.forEach(({ toEl: f, dx: u, dy: d, dw: $, dh: w }) => {
95
- f.style.transform = `translate(${(1 - a) * u}px,${(1 - a) * d}px) scale(${a + (1 - a) * $}, ${a + (1 - a) * w})`;
151
+ tick: (h) => {
152
+ p.forEach(({ toEl: $, dx: u, dy: g, dw: f, dh: w }) => {
153
+ $.style.transform = `translate(${(1 - h) * u}px,${(1 - h) * g}px) scale(${h + (1 - h) * f}, ${h + (1 - h) * w})`;
96
154
  });
97
155
  },
98
156
  onEnd: () => {
99
157
  p.forEach(
100
158
  ({
101
- toEl: a,
102
- originalTransform: f,
159
+ toEl: h,
160
+ originalTransform: $,
103
161
  originalPosition: u,
104
- originalTransformOrigin: d
162
+ originalTransformOrigin: g,
163
+ originalZIndex: f
105
164
  }) => {
106
- a.style.transform = f, a.style.position = u, a.style.transformOrigin = d;
165
+ h.style.transform = $, h.style.position = u, h.style.transformOrigin = g, h.style.zIndex = f;
107
166
  }
108
167
  );
109
168
  }
110
169
  };
111
170
  },
112
- out: async (c) => ({
171
+ out: async (i) => ({
113
172
  onStart: () => {
114
- i = c, s && (s(!0), s = null);
173
+ e = i, l && (l(!0), l = null);
115
174
  },
116
175
  prepare: (o) => {
117
- k(o), o.style.opacity = "0";
176
+ x(o), o.style.opacity = "0";
118
177
  }
119
178
  })
120
179
  };
121
180
  };
122
181
  function S(t, n) {
123
- const e = t.getBoundingClientRect(), i = n.getBoundingClientRect();
182
+ const s = t.getBoundingClientRect(), e = n.getBoundingClientRect();
124
183
  return new DOMRect(
125
- i.left - e.left,
126
- i.top - e.top,
127
- i.width,
128
- i.height
184
+ e.left - s.left,
185
+ e.top - s.top,
186
+ e.width,
187
+ e.height
129
188
  );
130
189
  }
131
- function H({
190
+ function C({
132
191
  detailRect: t,
133
192
  galleryRect: n,
134
- pageRect: e,
135
- scrollOffset: i
136
- }, s) {
137
- const l = n.left - t.left + (n.width - t.width) / 2 - i.x, r = n.top - t.top + (n.height - t.height) / 2 - i.y, c = n.width / t.width, o = n.height / t.height, h = Math.max(c, o), g = t.top / e.height * 100, y = (e.width - (t.left + t.width)) / e.width * 100, p = (e.height - (t.top + t.height)) / e.height * 100, a = t.left / e.width * 100;
138
- return s.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (f) => {
139
- const u = 1 - f, d = g * u, $ = y * u, w = p * u, x = a * u;
140
- s.style.clipPath = `inset(${d}% ${$}% ${w}% ${x}%)`, s.style.transform = `translate(${l * u}px, ${r * u}px) scale(${1 + (h - 1) * u})`;
193
+ pageRect: s,
194
+ scrollOffset: e
195
+ }, l) {
196
+ const r = n.left - t.left + (n.width - t.width) / 2 - e.x, a = n.top - t.top + (n.height - t.height) / 2 - e.y, i = n.width / t.width, o = n.height / t.height, c = Math.max(i, o), y = t.top / s.height * 100, d = (s.width - (t.left + t.width)) / s.width * 100, p = (s.height - (t.top + t.height)) / s.height * 100, h = t.left / s.width * 100;
197
+ return l.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, ($) => {
198
+ const u = 1 - $, g = y * u, f = d * u, w = p * u, k = h * u;
199
+ l.style.clipPath = `inset(${g}% ${f}% ${w}% ${k}%)`, l.style.transform = `translate(${r * u}px, ${a * u}px) scale(${1 + (c - 1) * u})`;
141
200
  };
142
201
  }
143
- function b({
202
+ function M({
144
203
  galleryRect: t,
145
204
  detailRect: n,
146
- scrollOffset: e
147
- }, i) {
148
- const s = n.left - t.left + (n.width - t.width) / 2 + e.x, l = n.top - t.top + (n.height - t.height) / 2 + e.y, r = n.width / t.width, c = n.height / t.height, o = Math.max(r, c);
149
- return (h) => {
150
- i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`;
151
- const g = 1 - h;
152
- i.style.transform = `translate(${s * g - e.x}px, ${l * g - e.y}px) scale(${1 + (o - 1) * g})`, i.style.opacity = `${1 - g}`;
205
+ scrollOffset: s
206
+ }, e) {
207
+ const l = n.left - t.left + (n.width - t.width) / 2 + s.x, r = n.top - t.top + (n.height - t.height) / 2 + s.y, a = n.width / t.width, i = n.height / t.height, o = Math.max(a, i);
208
+ return (c) => {
209
+ e.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`;
210
+ const y = 1 - c;
211
+ e.style.transform = `translate(${l * y - s.x}px, ${r * y - s.y}px) scale(${1 + (o - 1) * y})`, e.style.opacity = `${1 - y}`;
153
212
  };
154
213
  }
155
214
  function O({
156
215
  galleryRect: t,
157
216
  detailRect: n,
158
- scrollOffset: e
159
- }, i) {
160
- const s = n.left - t.left + (n.width - t.width) / 2 - e.x, l = n.top - t.top + (n.height - t.height) / 2 - e.y, r = n.width / t.width, c = n.height / t.height, o = Math.max(r, c);
161
- return (h) => {
162
- const g = 1 - h, y = h;
163
- i.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, i.style.transform = `translate(${s * g}px, ${l * g}px) scale(${1 + (o - 1) * g})`, i.style.opacity = `${y}`;
217
+ scrollOffset: s
218
+ }, e) {
219
+ const l = n.left - t.left + (n.width - t.width) / 2 - s.x, r = n.top - t.top + (n.height - t.height) / 2 - s.y, a = n.width / t.width, i = n.height / t.height, o = Math.max(a, i);
220
+ return (c) => {
221
+ const y = 1 - c, d = c;
222
+ e.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, e.style.transform = `translate(${l * y}px, ${r * y}px) scale(${1 + (o - 1) * y})`, e.style.opacity = `${d}`;
164
223
  };
165
224
  }
166
- function F({
225
+ function _({
167
226
  detailRect: t,
168
227
  galleryRect: n,
169
- pageRect: e,
170
- scrollOffset: i
171
- }, s) {
172
- const l = n.left - t.left + (n.width - t.width) / 2 + i.x, r = n.top - t.top + (n.height - t.height) / 2 + i.y, c = n.width / t.width, o = n.height / t.height, h = Math.min(c, o), g = t.top / e.height * 100, y = (e.width - (t.left + t.width)) / e.width * 100, p = (e.height - (t.top + t.height)) / e.height * 100, a = t.left / e.width * 100;
173
- return s.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, (f) => {
174
- const u = 1 - f, d = g * u, $ = y * u, w = p * u, x = a * u;
175
- s.style.clipPath = `inset(${d}% ${$}% ${w}% ${x}%)`, s.style.transform = `translate(${l * u - i.x}px, ${r * u - i.y}px) scale(${1 + (h - 1) * u})`;
228
+ pageRect: s,
229
+ scrollOffset: e
230
+ }, l) {
231
+ const r = n.left - t.left + (n.width - t.width) / 2 + e.x, a = n.top - t.top + (n.height - t.height) / 2 + e.y, i = n.width / t.width, o = n.height / t.height, c = Math.min(i, o), y = t.top / s.height * 100, d = (s.width - (t.left + t.width)) / s.width * 100, p = (s.height - (t.top + t.height)) / s.height * 100, h = t.left / s.width * 100;
232
+ return l.style.transformOrigin = `${t.left + t.width / 2}px ${t.top + t.height / 2}px`, ($) => {
233
+ const u = 1 - $, g = y * u, f = d * u, w = p * u, k = h * u;
234
+ l.style.clipPath = `inset(${g}% ${f}% ${w}% ${k}%)`, l.style.transform = `translate(${r * u - e.x}px, ${a * u - e.y}px) scale(${1 + (c - 1) * u})`;
176
235
  };
177
236
  }
178
- function I(t, n, e) {
179
- const i = t.querySelector(
237
+ function U(t, n, s) {
238
+ const e = t.querySelector(
180
239
  "[data-pinterest-detail-key]"
181
- ), s = n.querySelector(
240
+ ), l = n.querySelector(
182
241
  "[data-pinterest-detail-key]"
183
242
  );
184
243
  if (t.querySelectorAll("[data-pinterest-detail-key]").length > 1 || n.querySelectorAll("[data-pinterest-detail-key]").length > 1)
185
244
  return null;
186
- let l = null, r = null, c = !1;
187
- if (!i && s) {
188
- r = s;
189
- const y = r.getAttribute("data-pinterest-detail-key");
190
- if (!y) return null;
191
- l = t.querySelector(
192
- `[data-pinterest-gallery-key="${y}"]`
193
- ), l && (c = !0);
194
- } else if (i && !s) {
195
- r = i;
196
- const y = r.getAttribute("data-pinterest-detail-key");
197
- if (!y) return null;
198
- l = n.querySelector(
199
- `[data-pinterest-gallery-key="${y}"]`
200
- ), l && (c = !1);
245
+ let r = null, a = null, i = !1;
246
+ if (!e && l) {
247
+ a = l;
248
+ const d = a.getAttribute("data-pinterest-detail-key");
249
+ if (!d) return null;
250
+ r = t.querySelector(
251
+ `[data-pinterest-gallery-key="${d}"]`
252
+ ), r && (i = !0);
253
+ } else if (e && !l) {
254
+ a = e;
255
+ const d = a.getAttribute("data-pinterest-detail-key");
256
+ if (!d) return null;
257
+ r = n.querySelector(
258
+ `[data-pinterest-gallery-key="${d}"]`
259
+ ), r && (i = !1);
201
260
  }
202
- if (!l || !r)
261
+ if (!r || !a)
203
262
  return null;
204
- const o = S(c ? t : n, l), h = S(c ? n : t, r), g = n.getBoundingClientRect();
205
- return c ? {
206
- inAnimation: H(
207
- { detailRect: h, galleryRect: o, pageRect: g, scrollOffset: e },
263
+ const o = S(i ? t : n, r), c = S(i ? n : t, a), y = n.getBoundingClientRect();
264
+ return i ? {
265
+ inAnimation: C(
266
+ { detailRect: c, galleryRect: o, pageRect: y, scrollOffset: s },
208
267
  n
209
268
  ),
210
- outAnimation: b(
211
- { galleryRect: o, detailRect: h, scrollOffset: e },
269
+ outAnimation: M(
270
+ { galleryRect: o, detailRect: c, scrollOffset: s },
212
271
  t
213
272
  )
214
273
  } : {
215
274
  inAnimation: O(
216
- { galleryRect: o, detailRect: h, scrollOffset: e },
275
+ { galleryRect: o, detailRect: c, scrollOffset: s },
217
276
  n
218
277
  ),
219
- outAnimation: F(
220
- { detailRect: h, galleryRect: o, pageRect: g, scrollOffset: e },
278
+ outAnimation: _(
279
+ { detailRect: c, galleryRect: o, pageRect: y, scrollOffset: s },
221
280
  t
222
281
  )
223
282
  };
224
283
  }
225
- const m = (t = {}) => {
226
- var r, c;
284
+ const N = (t = {}) => {
285
+ var a, i;
227
286
  const n = {
228
- stiffness: ((r = t.spring) == null ? void 0 : r.stiffness) ?? 50,
229
- damping: ((c = t.spring) == null ? void 0 : c.damping) ?? 10
230
- }, e = t.timeout ?? 300;
231
- let i = null, s = null, l = null;
287
+ stiffness: ((a = t.spring) == null ? void 0 : a.stiffness) ?? 50,
288
+ damping: ((i = t.spring) == null ? void 0 : i.damping) ?? 10
289
+ }, s = t.timeout ?? 300;
290
+ let e = null, l = null, r = null;
232
291
  return {
233
- in: async (o, { scrollOffset: h }) => {
234
- const g = o;
292
+ in: async (o, { scrollOffset: c }) => {
293
+ const y = o;
235
294
  return !await new Promise((p) => {
236
- i ? p(!0) : (s = p, setTimeout(() => {
237
- s = null, p(!1);
238
- }, e));
239
- }) || !i ? (i = null, {
295
+ e ? p(!0) : (l = p, setTimeout(() => {
296
+ l = null, p(!1);
297
+ }, s));
298
+ }) || !e ? (e = null, {
240
299
  spring: n,
241
300
  tick: () => {
242
301
  }
243
- }) : (l = I(i, g, h), l ? (i = null, {
302
+ }) : (r = U(e, y, c), r ? (e = null, {
244
303
  spring: n,
245
304
  tick: (p) => {
246
- l && l.inAnimation(p);
305
+ r && r.inAnimation(p);
247
306
  }
248
307
  }) : {
249
308
  spring: n,
@@ -254,52 +313,49 @@ const m = (t = {}) => {
254
313
  out: async (o) => ({
255
314
  spring: n,
256
315
  onStart: () => {
257
- i = o, s && (s(!0), s = null);
316
+ e = o, l && (l(!0), l = null);
258
317
  },
259
- prepare: (h) => {
260
- k(h), h.style.zIndex = "-1";
318
+ prepare: (c) => {
319
+ x(c), c.style.zIndex = "-1";
261
320
  },
262
- tick: (h) => {
263
- l && l.outAnimation(h);
321
+ tick: (c) => {
322
+ r && r.outAnimation(c);
264
323
  }
265
324
  })
266
325
  };
267
- };
268
- function B(t) {
269
- const n = t.getBoundingClientRect(), e = t.clientHeight, s = 50 * (window.innerHeight - n.top) / e;
270
- return Math.min(Math.max(s, 0), 100);
271
- }
272
- const z = (t = {}) => {
273
- var e, i;
274
- const n = {
275
- stiffness: ((e = t.spring) == null ? void 0 : e.stiffness) ?? 300,
276
- damping: ((i = t.spring) == null ? void 0 : i.damping) ?? 200
277
- };
326
+ }, I = {
327
+ stiffness: 30,
328
+ damping: 7
329
+ }, Z = (t = {}) => {
330
+ var l, r;
331
+ const n = t.direction ?? "up", s = {
332
+ stiffness: ((l = t.spring) == null ? void 0 : l.stiffness) ?? I.stiffness,
333
+ damping: ((r = t.spring) == null ? void 0 : r.damping) ?? I.damping
334
+ }, e = n === "up";
278
335
  return {
279
- in: (s) => {
280
- const l = B(s);
281
- return {
282
- spring: n,
283
- tick: (r) => {
284
- s.style.clipPath = `circle(${r * 100}% at 50% ${l}%)`;
285
- }
286
- };
287
- },
288
- out: (s) => {
289
- const l = B(s);
290
- return {
291
- spring: n,
292
- tick: (r) => {
293
- s.style.clipPath = `circle(${r * 100}% at 50% ${l}%)`, s.style.zIndex = "100";
294
- },
295
- prepare: k
296
- };
297
- }
336
+ in: (a) => ({
337
+ spring: s,
338
+ tick: (i) => {
339
+ const o = e ? (1 - i) * 100 : (1 - i) * -100;
340
+ a.style.transform = `translateY(${o}vh)`;
341
+ }
342
+ }),
343
+ out: (a) => ({
344
+ spring: s,
345
+ tick: (i) => {
346
+ const o = e ? (1 - i) * -100 : (1 - i) * 100;
347
+ a.style.transform = `translateY(${o}vh)`;
348
+ },
349
+ prepare: (i) => {
350
+ x(i), i.style.zIndex = e ? "-1" : "1";
351
+ }
352
+ })
298
353
  };
299
354
  };
300
355
  export {
301
- X as fade,
302
- Y as hero,
303
- m as pinterest,
304
- z as ripple
356
+ b as drill,
357
+ v as fade,
358
+ H as hero,
359
+ N as pinterest,
360
+ Z as scroll
305
361
  };
@@ -0,0 +1,8 @@
1
+ import { SpringConfig, SggoiTransition } from '../types';
2
+ interface ScrollOptions {
3
+ direction?: "up" | "down";
4
+ spring?: Partial<SpringConfig>;
5
+ }
6
+ export declare const scroll: (options?: ScrollOptions) => SggoiTransition;
7
+ export {};
8
+ //# sourceMappingURL=scroll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll.d.ts","sourceRoot":"","sources":["../../src/lib/view-transitions/scroll.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG9D,UAAU,aAAa;IACrB,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;CAChC;AAOD,eAAO,MAAM,MAAM,GAAI,UAAS,aAAkB,KAAG,eAkCpD,CAAC"}