@ssgoi/core 6.3.1 → 6.5.0-beta.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 +93 -140
- package/dist/index.cjs +13 -13
- package/dist/index.js +792 -717
- package/dist/internal.cjs +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +515 -363
- package/dist/ssgoi-transition/create-ssgoi-transition-context.d.ts.map +1 -1
- package/dist/ssgoi-transition/observe-ssgoi-transitions.d.ts +3 -0
- package/dist/ssgoi-transition/observe-ssgoi-transitions.d.ts.map +1 -0
- package/dist/ssgoi-transition/unmount-observer.d.ts.map +1 -1
- package/dist/ssgoi-transition/visibility-observer.d.ts +66 -0
- package/dist/ssgoi-transition/visibility-observer.d.ts.map +1 -0
- package/dist/transitions/axis/provider/x/fluid.d.ts.map +1 -1
- package/dist/transitions/axis/provider/x/snappy.d.ts.map +1 -1
- package/dist/transitions/axis/provider/y/directional.d.ts.map +1 -1
- package/dist/transitions/axis/provider/y/non-directional.d.ts.map +1 -1
- package/dist/transitions/axis/provider/z/directional.d.ts.map +1 -1
- package/dist/transitions/axis/provider/z/non-directional.d.ts.map +1 -1
- package/dist/transitions/axis/transition.d.ts.map +1 -1
- package/dist/transitions/blind/transition.d.ts +1 -0
- package/dist/transitions/blind/transition.d.ts.map +1 -1
- package/dist/transitions/drill/transition.d.ts.map +1 -1
- package/dist/transitions/fade/transition.d.ts.map +1 -1
- package/dist/transitions/film/transition.d.ts.map +1 -1
- package/dist/transitions/hero/provider/chrome/static.d.ts.map +1 -1
- package/dist/transitions/jaemin/transition.d.ts.map +1 -1
- package/dist/transitions/rotate/transition.d.ts.map +1 -1
- package/dist/transitions/scroll/transition.d.ts.map +1 -1
- package/dist/transitions/sheet/transition.d.ts.map +1 -1
- package/dist/transitions/slide/transition.d.ts.map +1 -1
- package/dist/transitions/strip/transition.d.ts.map +1 -1
- package/dist/transitions/zoom/transition.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/internal.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ut=Object.defineProperty;var ft=(t,n,e)=>n in t?ut(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var W=(t,n,e)=>ft(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("./multi-animation-Dw2JTJI2.cjs");class st extends H.Animation{constructor(){super(...arguments);W(this,"child",null);W(this,"_state","idle");W(this,"_settled",!1);W(this,"listeners",new Set)}attach(e){const o=this.child;if(this.child=e,this._settled=!1,o){const m=o.getPose();o.complete(),e.matchInto(m)}e.playbackRate=this.playbackRate;const c=e.onComplete;e.onComplete=()=>{c==null||c(),this.child===e&&(this.child=null,this._state="idle",this._settled=!0),this.notify()};const d=e.onUpdate;e.onUpdate=m=>{var S;d==null||d(m),(S=this.onUpdate)==null||S.call(this,m),this.notify()},this._state==="paused"?e.pause():this._state==="reversing"?e.reverse():(this._state="playing",e.play()),this.notify()}play(){var e;this._state="playing",this._settled=!1,(e=this.child)==null||e.play(),this.notify()}reverse(){var e;this._state="reversing",this._settled=!1,(e=this.child)==null||e.reverse(),this.notify()}pause(){var e;this._state="paused",(e=this.child)==null||e.pause(),this.notify()}complete(){var e;(e=this.child)==null||e.complete(),this.notify()}get isAnimating(){var e;return((e=this.child)==null?void 0:e.isAnimating)??!1}get isPaused(){return this._state==="paused"}get isComplete(){return this._settled&&!this.child}get isReversing(){var e;return((e=this.child)==null?void 0:e.isReversing)??this._state==="reversing"}get progress(){var e;return((e=this.child)==null?void 0:e.progress)??0}findTimeForProgress(e){var o;return((o=this.child)==null?void 0:o.findTimeForProgress(e))??null}get playbackRate(){return super.playbackRate}set playbackRate(e){super.playbackRate=e,this.child&&(this.child.playbackRate=e),this.notify()}getPose(){var e;return((e=this.child)==null?void 0:e.getPose())??[]}getTimeline(){var e;return((e=this.child)==null?void 0:e.getTimeline())??[]}matchInto(e){var o;(o=this.child)==null||o.matchInto(e)}get activeChild(){return this.child}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(){for(const e of this.listeners)e()}}const dt=(t,n)=>{var e;t.style.position="absolute",t.style.width="100%",t.style.top=`${-1*(((e=n==null?void 0:n.scrollOffset)==null?void 0:e.y)??0)}px`,t.style.left="0"},Q=new Set(["auto","scroll","overlay"]),mt=t=>{let n=t.parentElement;for(;n&&n!==document.body;){const e=window.getComputedStyle(n);if(Q.has(e.overflowY)||Q.has(e.overflowX))return n;n=n.parentElement}return document.documentElement},ht=t=>{let n=t.parentElement;for(;n&&n!==document.body;){const e=window.getComputedStyle(n).position;if(e==="relative"||e==="absolute"||e==="fixed"||e==="sticky")return n;n=n.parentElement}return document.body};function gt(t){const n=Object.keys(t);return Promise.all(n.map(e=>t[e])).then(e=>{const o={};return n.forEach((c,d)=>{o[c]=e[d]}),o})}function yt(t){const n=t.filter(e=>e.symmetric).map(e=>({from:e.to,to:e.from,transition:e.transition}));return[...t,...n]}function F(t,n){if(n==="*")return!0;if(n.endsWith("/*")){const e=n.slice(0,-1);return t.startsWith(e)&&t.length>e.length}return t===n}function pt(t,n,e){for(const o of e)if(F(t,o.from)&&F(n,o.to))return o.transition;for(const o of e)if((o.from==="*"||F(t,o.from))&&(o.to==="*"||F(n,o.to)))return o.transition;return null}const vt=768,Et=10,wt=10;function St(t={}){const{preserveScroll:n=i=>i}=t,e=typeof n=="function"?n:()=>n;let o=null,c=!1,d=!1;const m=()=>{const i=(o==null?void 0:o.clientWidth)??0,l=i>0?i:typeof window<"u"?window.innerWidth:0;return l>0&&l<vt},S=()=>(d||(c=m(),d=!0),c),y=i=>{var v;const l=e(S());if(l===!1)return{preserves:!1,shared:!1,storageKey:`path:${i}`};if(l===!0)return{preserves:!0,shared:!1,storageKey:`path:${i}`};const g=((v=l.exclude)==null?void 0:v.some(r=>F(i,r)))??!1,p=!g&&!!l.key;return{preserves:!g,shared:p,storageKey:p?`shared:${l.key}`:`path:${i}`}},x=i=>y(i).preserves;let R=null;const h=new Map;let T=null,A=!1,O=0;const I=()=>{o&&T&&!A&&h.set(y(T).storageKey,{x:o.scrollLeft,y:o.scrollTop})},L=i=>{if(!o)return;const l=y(i);if(l.preserves&&l.shared&&!h.has(l.storageKey))return;const g=l.preserves&&h.has(l.storageKey)?h.get(l.storageKey):{x:0,y:0};let p=0;const v=()=>{if(!o)return;o.scrollTo({top:g.y,left:g.x}),!(Math.abs(o.scrollTop-g.y)<1&&Math.abs(o.scrollLeft-g.x)<1)&&p<Et&&(p++,requestAnimationFrame(v))};requestAnimationFrame(v)};return{initializeContext:(i,l)=>{A=!0;const g=++O;R=i,o||(o=mt(i),c=m(),d=!0,typeof ResizeObserver<"u"&&new ResizeObserver(()=>{c=m()}).observe(o),(o===document.documentElement?window:o).addEventListener("scroll",I,{passive:!0})),T=l,L(l);let p=0;const v=()=>{g===O&&(p++,p>=wt?A=!1:requestAnimationFrame(v))};requestAnimationFrame(v)},calculateScrollOffset:(i,l)=>{const g=i?y(i).storageKey:null,p=g&&h.has(g)?h.get(g):{x:0,y:0},v=l?y(l):null,r=v!=null&&v.preserves?v.storageKey:null,s=r&&h.has(r)?h.get(r):{x:0,y:0};return{x:-s.x+p.x,y:-s.y+p.y}},evictScrollPosition:i=>{h.delete(y(i).storageKey)},shouldPreserve:x,getScrollContainer:()=>o,getPositionedParentElement:()=>R?ht(R):document.body,getScrollPosition:i=>{const l=i?y(i).storageKey:null;return l&&h.has(l)?h.get(l):{x:0,y:0}}}}const tt=30,et=8,nt=1.2,ot=30,bt=600;function Tt(){let t=null,n=!1,e=!1,o=null,c=null,d=!1;const m=(a,u)=>{for(let f=0;f<a.length;f++){const E=a.item(f);if(E&&E.identifier===u)return E}return null},S=()=>{o!==null&&(clearTimeout(o),o=null)},y=()=>{c!==null&&(clearTimeout(c),c=null)},x=()=>{n=!0,e=!0,S(),y(),o=setTimeout(()=>{n=!1,e=!1,o=null},bt)},R=a=>{if(a.touches.length!==1){t=null;return}const u=a.touches.item(0);if(!u){t=null;return}const f=window.innerWidth,E=u.clientX<=tt,P=u.clientX>=f-tt;if(!E&&!P){t=null;return}t={identifier:u.identifier,startX:u.clientX,startY:u.clientY,fromLeftEdge:E,moved:!1}},h=a=>{if(!t)return;if(a.touches.length!==1){t=null;return}const u=m(a.touches,t.identifier);if(!u){t=null;return}const f=u.clientX-t.startX,E=u.clientY-t.startY,P=Math.abs(f),i=Math.abs(E);if(i>et&&i>P*nt){t=null;return}const l=t.fromLeftEdge?f>0:f<0;P>et&&P>i*nt&&l&&(t.moved=!0)},T=a=>{if(!t)return;const u=m(a.changedTouches,t.identifier);if(!u){t=null;return}const f=u.clientX-t.startX,E=t.fromLeftEdge?f>0:f<0;if(t.moved&&E&&Math.abs(f)>=ot){x(),t=null;return}t.moved&&Math.abs(f)>=ot&&x(),t=null},A=()=>{t&&(t.moved&&x(),t=null)};return{initialize:()=>{if(typeof window>"u"||d)return;d=!0;const a={passive:!0,capture:!0};window.addEventListener("touchstart",R,a),window.addEventListener("touchmove",h,a),window.addEventListener("touchend",T,a),window.addEventListener("touchcancel",A,a)},destroy:()=>{if(typeof window>"u"||!d)return;d=!1;const a={capture:!0};window.removeEventListener("touchstart",R,a),window.removeEventListener("touchmove",h,a),window.removeEventListener("touchend",T,a),window.removeEventListener("touchcancel",A,a),S(),y(),t=null,n=!1,e=!1},isSwipeBack:()=>{const a=n||e;return a&&S(),a},onPageEnter:()=>{n=!1,S(),y(),c=setTimeout(()=>{e=!1,c=null},0)}}}function Pt(){let t=null;function n(){var o,c;t&&((o=t.outResolve)==null||o.call(t,null),(c=t.inResolve)==null||c.call(t,null),t=null)}function e(){if(t!=null&&t.from&&(t!=null&&t.to)&&(t!=null&&t.outResolve)&&(t!=null&&t.inResolve)){if(t.from===t.to){n();return}const o={from:t.from,to:t.to};t.outResolve(o),t.inResolve(o),t=null}}return{trigger(o,c){var m;c==="out"&&(t==null?void 0:t.to)===o&&!t.from&&((m=t.inResolve)==null||m.call(t,null),t={}),t&&(c==="out"&&t.from&&t.from!==o||c==="in"&&t.to&&t.to!==o)&&n(),t||(t={}),c==="out"?t.from=o:t.to=o},get(o){return new Promise(c=>{t||(t={}),o==="out"?t.outResolve=c:t.inResolve=c,e()})}}}const X=new Map;let z=null,rt=!1;function it(t){if(t instanceof HTMLElement&&X.has(t)){const n=X.get(t);X.delete(t),queueMicrotask(n)}for(const n of Array.from(t.childNodes))it(n)}function Rt(){if(rt||typeof document>"u")return;rt=!0,z=new MutationObserver(n=>{for(const e of n)for(const o of Array.from(e.removedNodes))it(o)});const t=()=>{z==null||z.observe(document.body,{childList:!0,subtree:!0})};document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}function At(t,n){return Rt(),X.set(t,n),()=>{X.delete(t)}}function xt(t){return Array.isArray(t)}function lt(t){const n=[];for(const e of t)xt(e)?n.push(...lt(e)):n.push(e);return n}function Lt(t,n={}){const{transitions:e=[],middleware:o=(r,s)=>({from:r,to:s}),preserveScroll:c=r=>r}=t,d=n.host??new st,m=Pt(),S=yt(lt(e)),y=Tt();y.initialize();const{initializeContext:x,calculateScrollOffset:R,evictScrollPosition:h,shouldPreserve:T,getScrollContainer:A,getPositionedParentElement:O,getScrollPosition:I}=St({preserveScroll:c});let L=null,k=null;const a=new WeakMap,u=r=>{a.set(r,{parent:r.parentElement,nextSibling:r.nextElementSibling})},f=r=>{const s=a.get(r);return s||{parent:r.parentElement,nextSibling:r.nextElementSibling}},E=(r,s,b,w,B)=>{const K=w.element,D=B.element,{parent:M,nextSibling:C}=w.parent?{parent:w.parent,nextSibling:w.nextSibling}:f(K),_=K.cloneNode(!0),q={scrollOffset:R(s,b),from:{scroll:I(s)},to:{scroll:I(b)},get scrollingElement(){return A()||document.documentElement},get positionedParent(){return O()}};dt(_,q),T(s)||h(s);const j=Promise.resolve(_),Z=Promise.resolve(D),J=[],ct={from:j,to:Z,context:q,createElement:((Y,$="div")=>{const N=document.createElement($);return N.setAttribute("data-ssgoi-id",Y),J.push(N),N})},at=Promise.resolve(r.prepare?r.prepare(ct):{});gt({from:j,to:Z,extras:at}).then(({from:Y,to:$,extras:N})=>{M&&(C&&M.contains(C)?M.insertBefore(_,C):M.appendChild(_));const G=r.animation({from:Y,to:$,context:q,...N}),U=G.onComplete;G.onComplete=()=>{U==null||U(),_.parentElement&&_.parentElement.removeChild(_);for(const V of J)V.parentElement&&V.parentElement.removeChild(V)},d.attach(G)})},P=(r,s)=>{const b=y.isSwipeBack();m.trigger(r,s),m.get(s).then(w=>{if(s==="in"&&y.onPageEnter(),!w)return;if(b){s==="out"&&w.from&&!T(w.from)&&h(w.from),L=null,k=null;return}if(s!=="in")return;const{from:B,to:K}=o(w.from,w.to),D=pt(B,K,S),M=L,C=k;L=null,k=null,!(!D||!M||!C)&&E(D,B,K,M,C)})},i=(r,s)=>{const b=f(r);L={element:r,parent:b.parent,nextSibling:b.nextSibling};const w=r.getAttribute("data-ssgoi-transition")??s;P(w,"out")},l=new WeakSet,g=(r,s)=>{l.has(s)||(l.add(s),u(s),x(s,r),k={element:s,parent:s.parentElement,nextSibling:s.nextElementSibling},P(r,"in"),At(s,()=>i(s,r)))},p=new Map;return{register:g,refFor:r=>{let s=p.get(r);return s||(s=b=>{b&&g(r,b)},p.set(r,s)),s}}}exports.Animation=H.Animation;exports.MultiAnimation=H.MultiAnimation;exports.WebAnimation=H.WebAnimation;exports.HostAnimation=st;exports.createSggoiTransitionContext=Lt;
|
|
1
|
+
"use strict";var Mt=Object.defineProperty;var xt=(t,s,e)=>s in t?Mt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e;var B=(t,s,e)=>xt(t,typeof s!="symbol"?s+"":s,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("./multi-animation-Dw2JTJI2.cjs");class Et extends Z.Animation{constructor(){super(...arguments);B(this,"child",null);B(this,"_state","idle");B(this,"_settled",!1);B(this,"listeners",new Set)}attach(e){const n=this.child;if(this.child=e,this._settled=!1,n){const c=n.getPose();n.complete(),e.matchInto(c)}e.playbackRate=this.playbackRate;const l=e.onComplete;e.onComplete=()=>{l==null||l(),this.child===e&&(this.child=null,this._state="idle",this._settled=!0),this.notify()};const f=e.onUpdate;e.onUpdate=c=>{var y;f==null||f(c),(y=this.onUpdate)==null||y.call(this,c),this.notify()},this._state==="paused"?e.pause():this._state==="reversing"?e.reverse():(this._state="playing",e.play()),this.notify()}play(){var e;this._state="playing",this._settled=!1,(e=this.child)==null||e.play(),this.notify()}reverse(){var e;this._state="reversing",this._settled=!1,(e=this.child)==null||e.reverse(),this.notify()}pause(){var e;this._state="paused",(e=this.child)==null||e.pause(),this.notify()}complete(){var e;(e=this.child)==null||e.complete(),this.notify()}get isAnimating(){var e;return((e=this.child)==null?void 0:e.isAnimating)??!1}get isPaused(){return this._state==="paused"}get isComplete(){return this._settled&&!this.child}get isReversing(){var e;return((e=this.child)==null?void 0:e.isReversing)??this._state==="reversing"}get progress(){var e;return((e=this.child)==null?void 0:e.progress)??0}findTimeForProgress(e){var n;return((n=this.child)==null?void 0:n.findTimeForProgress(e))??null}get playbackRate(){return super.playbackRate}set playbackRate(e){super.playbackRate=e,this.child&&(this.child.playbackRate=e),this.notify()}getPose(){var e;return((e=this.child)==null?void 0:e.getPose())??[]}getTimeline(){var e;return((e=this.child)==null?void 0:e.getTimeline())??[]}matchInto(e){var n;(n=this.child)==null||n.matchInto(e)}get activeChild(){return this.child}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(){for(const e of this.listeners)e()}}const Lt=(t,s)=>{var e;t.style.position="absolute",t.style.width="100%",t.style.top=`${-1*(((e=s==null?void 0:s.scrollOffset)==null?void 0:e.y)??0)}px`,t.style.left="0"},ht=new Set(["auto","scroll","overlay"]),Ot=t=>{let s=t.parentElement;for(;s&&s!==document.body;){const e=window.getComputedStyle(s);if(ht.has(e.overflowY)||ht.has(e.overflowX))return s;s=s.parentElement}return document.documentElement},_t=t=>{let s=t.parentElement;for(;s&&s!==document.body;){const e=window.getComputedStyle(s).position;if(e==="relative"||e==="absolute"||e==="fixed"||e==="sticky")return s;s=s.parentElement}return document.body};function kt(t){const s=Object.keys(t);return Promise.all(s.map(e=>t[e])).then(e=>{const n={};return s.forEach((l,f)=>{n[l]=e[f]}),n})}function Dt(t){const s=t.filter(e=>e.symmetric).map(e=>({from:e.to,to:e.from,transition:e.transition}));return[...t,...s]}function X(t,s){if(s==="*")return!0;if(s.endsWith("/*")){const e=s.slice(0,-1);return t.startsWith(e)&&t.length>e.length}return t===s}function Ht(t,s,e){for(const n of e)if(X(t,n.from)&&X(s,n.to))return n.transition;for(const n of e)if((n.from==="*"||X(t,n.from))&&(n.to==="*"||X(s,n.to)))return n.transition;return null}const Nt=768,It=10,Wt=10;function Ft(t={}){const{preserveScroll:s=a=>a}=t,e=typeof s=="function"?s:()=>s;let n=null,l=!1,f=!1;const c=()=>{const a=(n==null?void 0:n.clientWidth)??0,u=a>0?a:typeof window<"u"?window.innerWidth:0;return u>0&&u<Nt},y=()=>(f||(l=c(),f=!0),l),b=a=>{var S;const u=e(y());if(u===!1)return{preserves:!1,shared:!1,storageKey:`path:${a}`};if(u===!0)return{preserves:!0,shared:!1,storageKey:`path:${a}`};const v=((S=u.exclude)==null?void 0:S.some(A=>X(a,A)))??!1,w=!v&&!!u.key;return{preserves:!v,shared:w,storageKey:w?`shared:${u.key}`:`path:${a}`}},O=a=>b(a).preserves;let _=null;const E=new Map;let x=null,k=!1,I=0;const W=()=>{n&&x&&!k&&E.set(b(x).storageKey,{x:n.scrollLeft,y:n.scrollTop})},T=a=>{if(!n)return;const u=b(a);if(u.preserves&&u.shared&&!E.has(u.storageKey))return;const v=u.preserves&&E.has(u.storageKey)?E.get(u.storageKey):{x:0,y:0};let w=0;const S=()=>{if(!n)return;n.scrollTo({top:v.y,left:v.x}),!(Math.abs(n.scrollTop-v.y)<1&&Math.abs(n.scrollLeft-v.x)<1)&&w<It&&(w++,requestAnimationFrame(S))};requestAnimationFrame(S)};return{initializeContext:(a,u)=>{k=!0;const v=++I;_=a,n||(n=Ot(a),l=c(),f=!0,typeof ResizeObserver<"u"&&new ResizeObserver(()=>{l=c()}).observe(n),(n===document.documentElement?window:n).addEventListener("scroll",W,{passive:!0})),x=u,T(u);let w=0;const S=()=>{v===I&&(w++,w>=Wt?k=!1:requestAnimationFrame(S))};requestAnimationFrame(S)},calculateScrollOffset:(a,u)=>{const v=a?b(a).storageKey:null,w=v&&E.has(v)?E.get(v):{x:0,y:0},S=u?b(u):null,A=S!=null&&S.preserves?S.storageKey:null,F=A&&E.has(A)?E.get(A):{x:0,y:0};return{x:-F.x+w.x,y:-F.y+w.y}},evictScrollPosition:a=>{E.delete(b(a).storageKey)},shouldPreserve:O,getScrollContainer:()=>n,getPositionedParentElement:()=>_?_t(_):document.body,getScrollPosition:a=>{const u=a?b(a).storageKey:null;return u&&E.has(u)?E.get(u):{x:0,y:0}}}}const yt=30,mt=8,pt=1.2,gt=30,Kt=600;function Bt(){let t=null,s=!1,e=!1,n=null,l=null,f=!1;const c=(d,g)=>{for(let m=0;m<d.length;m++){const p=d.item(m);if(p&&p.identifier===g)return p}return null},y=()=>{n!==null&&(clearTimeout(n),n=null)},b=()=>{l!==null&&(clearTimeout(l),l=null)},O=()=>{s=!0,e=!0,y(),b(),n=setTimeout(()=>{s=!1,e=!1,n=null},Kt)},_=d=>{if(d.touches.length!==1){t=null;return}const g=d.touches.item(0);if(!g){t=null;return}const m=window.innerWidth,p=g.clientX<=yt,R=g.clientX>=m-yt;if(!p&&!R){t=null;return}t={identifier:g.identifier,startX:g.clientX,startY:g.clientY,fromLeftEdge:p,moved:!1}},E=d=>{if(!t)return;if(d.touches.length!==1){t=null;return}const g=c(d.touches,t.identifier);if(!g){t=null;return}const m=g.clientX-t.startX,p=g.clientY-t.startY,R=Math.abs(m),a=Math.abs(p);if(a>mt&&a>R*pt){t=null;return}const u=t.fromLeftEdge?m>0:m<0;R>mt&&R>a*pt&&u&&(t.moved=!0)},x=d=>{if(!t)return;const g=c(d.changedTouches,t.identifier);if(!g){t=null;return}const m=g.clientX-t.startX,p=t.fromLeftEdge?m>0:m<0;if(t.moved&&p&&Math.abs(m)>=gt){O(),t=null;return}t.moved&&Math.abs(m)>=gt&&O(),t=null},k=()=>{t&&(t.moved&&O(),t=null)};return{initialize:()=>{if(typeof window>"u"||f)return;f=!0;const d={passive:!0,capture:!0};window.addEventListener("touchstart",_,d),window.addEventListener("touchmove",E,d),window.addEventListener("touchend",x,d),window.addEventListener("touchcancel",k,d)},destroy:()=>{if(typeof window>"u"||!f)return;f=!1;const d={capture:!0};window.removeEventListener("touchstart",_,d),window.removeEventListener("touchmove",E,d),window.removeEventListener("touchend",x,d),window.removeEventListener("touchcancel",k,d),y(),b(),t=null,s=!1,e=!1},isSwipeBack:()=>{const d=s||e;return d&&y(),d},onPageEnter:()=>{s=!1,y(),b(),l=setTimeout(()=>{e=!1,l=null},0)}}}function Xt(){let t=null;function s(){var n,l;t&&((n=t.outResolve)==null||n.call(t,null),(l=t.inResolve)==null||l.call(t,null),t=null)}function e(){if(t!=null&&t.from&&(t!=null&&t.to)&&(t!=null&&t.outResolve)&&(t!=null&&t.inResolve)){if(t.from===t.to){s();return}const n={from:t.from,to:t.to};t.outResolve(n),t.inResolve(n),t=null}}return{trigger(n,l){var c;l==="out"&&(t==null?void 0:t.to)===n&&!t.from&&((c=t.inResolve)==null||c.call(t,null),t={}),t&&(l==="out"&&t.from&&t.from!==n||l==="in"&&t.to&&t.to!==n)&&s(),t||(t={}),l==="out"?t.from=n:t.to=n},get(n){return new Promise(l=>{t||(t={}),n==="out"?t.outResolve=l:t.inResolve=l,e()})}}}const $=new Map;let Y=null,vt=!1;function St(t){if(t instanceof HTMLElement&&$.has(t)&&!t.isConnected){const s=$.get(t);$.delete(t),queueMicrotask(s)}for(const s of Array.from(t.childNodes))St(s)}function zt(){if(vt||typeof document>"u")return;vt=!0,Y=new MutationObserver(s=>{for(const e of s)for(const n of Array.from(e.removedNodes))St(n)});const t=()=>{Y==null||Y.observe(document.body,{childList:!0,subtree:!0})};document.body?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}function $t(t,s){return zt(),$.set(t,s),()=>{$.delete(t)}}const it=new WeakMap;let G=null;const j="none !important";function z(t){const s=t.style.getPropertyValue("display");return t.style.getPropertyPriority("display")?`${s} !important`:s}function qt(){return G||(G=new MutationObserver(t=>{for(const s of t){const e=s.target,n=it.get(e);if(!n)continue;const l=z(e);l!==n.accounted&&(n.accounted=l,l===j?(n.reactHidden=!0,n.onHide()):l!=="none"&&n.reactHidden&&(n.reactHidden=!1,n.onShow()))}}),G)}function Vt(t,s){const e=z(t),n={accounted:e,reactHidden:e===j,onHide:s.onHide,onShow:s.onShow};return it.set(t,n),qt().observe(t,{attributes:!0,attributeFilter:["style"]}),{get isHidden(){return z(t)===j},setDisplay(l,f=!1){l===null?t.style.removeProperty("display"):t.style.setProperty("display",l,f?"important":""),n.accounted=z(t)},sync(){n.accounted=z(t),n.reactHidden=n.accounted===j},stop(){it.delete(t)}}}function Ut(t){return Array.isArray(t)}function wt(t){const s=[];for(const e of t)Ut(e)?s.push(...wt(e)):s.push(e);return s}function Yt(t,s={}){const{transitions:e=[],middleware:n=(o,i)=>({from:o,to:i}),preserveScroll:l=o=>o}=t,f=s.host??new Et,c=Xt(),y=Dt(wt(e)),b=Bt();b.initialize();const{initializeContext:O,calculateScrollOffset:_,evictScrollPosition:E,shouldPreserve:x,getScrollContainer:k,getPositionedParentElement:I,getScrollPosition:W}=Ft({preserveScroll:l});let T=null,P=null;const d=new WeakMap,g=o=>{d.set(o,{parent:o.parentElement,nextSibling:o.nextElementSibling})},m=o=>{const i=d.get(o);return i||{parent:o.parentElement,nextSibling:o.nextElementSibling}},p=new WeakMap,R=new WeakMap;let a=0;const u=o=>{const i=typeof getComputedStyle<"u"?getComputedStyle(o).display:"";return i&&i!=="none"?i:"block"},v=(o,i)=>{i.visibleDisplay=o.style.getPropertyValue("display"),i.computedDisplay=u(o)},w=(o,i)=>{if(R.get(o)!==i)return;R.delete(o);const r=p.get(o);r&&(r.savedCss!==null&&(o.style.cssText=r.savedCss,r.savedCss=null),r.intent==="hidden"?r.vis.setDisplay("none",!0):r.visibleDisplay?(r.vis.setDisplay(r.visibleDisplay,!1),v(o,r)):(r.vis.setDisplay(null),v(o,r)))},S=(o,i,r,h,L)=>{const M=h.element,D=L.element,H=(h.mode??"unmount")==="hidden",{parent:q,nextSibling:Q}=h.parent?{parent:h.parent,nextSibling:h.nextSibling}:m(M),V=_(i,r),tt={scrollOffset:V,from:{scroll:W(i)},to:{scroll:W(r)},get scrollingElement(){return k()||document.documentElement},get positionedParent(){return I()}};let C;if(H){C=M,C.style.top=`${-1*((V==null?void 0:V.y)??0)}px`;const N=p.get(D);N&&N.savedCss===null&&(N.savedCss=D.style.cssText)}else C=M.cloneNode(!0),C.setAttribute("data-ssgoi-clone",""),Lt(C,tt);x(i)||E(i);const U=H?++a:0;H&&(R.set(D,U),R.set(M,U));const ut=Promise.resolve(C),dt=Promise.resolve(D),ft=[],Pt={from:ut,to:dt,context:tt,createElement:((N,et="div")=>{const K=document.createElement(et);return K.setAttribute("data-ssgoi-id",N),ft.push(K),K})},Ct=Promise.resolve(o.prepare?o.prepare(Pt):{});kt({from:ut,to:dt,extras:Ct}).then(({from:N,to:et,extras:K})=>{!H&&q&&(Q&&q.contains(Q)?q.insertBefore(C,Q):q.appendChild(C));const nt=o.animation({from:N,to:et,context:tt,...K}),st=nt.onComplete;nt.onComplete=()=>{st==null||st(),H?(w(M,U),w(D,U)):C.parentElement&&C.parentElement.removeChild(C);for(const ot of ft)ot.parentElement&&ot.parentElement.removeChild(ot)},f.attach(nt)})},A=(o,i)=>{const r=b.isSwipeBack();c.trigger(o,i),c.get(i).then(h=>{if(i==="in"&&b.onPageEnter(),!h)return;if(r){i==="out"&&h.from&&!x(h.from)&&E(h.from),T=null,P=null;return}if(i!=="in")return;const{from:L,to:M}=n(h.from,h.to),D=Ht(L,M,y),J=T,H=P;T=null,P=null,!(!D||!J||!H)&&S(D,L,M,J,H)})},F=(o,i)=>{const r=p.get(o);if(!r)return;const h=r.intent==="hidden";if(r.intent="hidden",r.savedCss===null&&(r.savedCss=o.style.cssText),r.vis.setDisplay(r.computedDisplay||"block",!0),o.style.position="absolute",o.style.width="100%",o.style.left="0",h)return;const L=m(o);T={element:o,parent:L.parent,nextSibling:L.nextSibling,mode:"hidden"};const M=o.getAttribute("data-ssgoi-transition")??i;A(M,"out")},Rt=(o,i)=>{const r=p.get(o);if(!r||r.intent==="visible")return;r.intent="visible",v(o,r),r.savedCss!==null&&(o.style.cssText=r.savedCss,r.visibleDisplay?r.vis.setDisplay(r.visibleDisplay,!1):r.vis.setDisplay(null)),O(o,i),P={element:o,parent:o.parentElement,nextSibling:o.nextElementSibling};const h=o.getAttribute("data-ssgoi-transition")??i;A(h,"in")},At=(o,i)=>{const r=p.get(o);if(r&&(r.vis.stop(),p.delete(o),R.delete(o),r.intent==="hidden")){(T==null?void 0:T.element)===o&&(T=null),(P==null?void 0:P.element)===o&&(P=null);return}const h=m(o);T={element:o,parent:h.parent,nextSibling:h.nextSibling,mode:"unmount"};const L=o.getAttribute("data-ssgoi-transition")??i;A(L,"out")},lt=new WeakSet,ct=(o,i)=>{if(lt.has(i))return;lt.add(i),g(i);const r=Vt(i,{onHide:()=>F(i,o),onShow:()=>Rt(i,o)}),h={vis:r,savedCss:null,intent:r.isHidden?"hidden":"visible",visibleDisplay:"",computedDisplay:"block"};p.set(i,h),r.isHidden||(v(i,h),O(i,o),P={element:i,parent:i.parentElement,nextSibling:i.nextElementSibling},A(o,"in")),$t(i,()=>At(i,o))},at=new Map;return{register:ct,refFor:o=>{let i=at.get(o);return i||(i=r=>{r&&ct(o,r)},at.set(o,i)),i}}}const Tt="data-ssgoi-root",Gt=`[${Tt}]`,rt="data-ssgoi-transition",bt=`[${rt}]`,jt="[data-ssgoi-clone]";function Zt(){return typeof MutationObserver<"u"&&typeof HTMLElement<"u"&&typeof Node<"u"}function Jt(t){return t.nodeType===Node.ELEMENT_NODE}function Qt(t){return t instanceof HTMLElement}function te(t,s){if(!Zt())return()=>{};t.setAttribute(Tt,"");const e=c=>c.closest(Gt)===t,n=c=>{if(!Qt(c)||!e(c)||c.closest(jt))return;const y=c.getAttribute(rt);y!==null&&s.register(y,c)},l=c=>{if(Jt(c)){c.matches(bt)&&n(c);for(const y of c.querySelectorAll(bt))n(y)}},f=new MutationObserver(c=>{for(const y of c){if(y.type==="attributes"){n(y.target);continue}for(const b of y.addedNodes)l(b)}});return f.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[rt]}),l(t),()=>f.disconnect()}exports.Animation=Z.Animation;exports.MultiAnimation=Z.MultiAnimation;exports.WebAnimation=Z.WebAnimation;exports.HostAnimation=Et;exports.createSggoiTransitionContext=Yt;exports.observeSsgoiTransitions=te;
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { createSggoiTransitionContext } from './ssgoi-transition/create-ssgoi-transition-context';
|
|
2
|
+
export { observeSsgoiTransitions } from './ssgoi-transition/observe-ssgoi-transitions';
|
|
2
3
|
export { Animation, WebAnimation, MultiAnimation, HostAnimation, } from './animation';
|
|
3
4
|
export type { SsgoiConfig, SsgoiContext, SsgoiPathTransition, SsgoiPathTransitionInput, TransitionConfig, PrepareArgs, AnimationFactoryArgs, CreateElement, SsgoiTransitionContext, Pose, Timeline, } from './types/index.ts';
|
|
4
5
|
//# sourceMappingURL=internal.d.ts.map
|
package/dist/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/lib/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAClG,OAAO,EACL,SAAS,EACT,YAAY,EACZ,cAAc,EACd,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EACtB,IAAI,EACJ,QAAQ,GACT,MAAM,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/lib/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAClG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EACL,SAAS,EACT,YAAY,EACZ,cAAc,EACd,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EACtB,IAAI,EACJ,QAAQ,GACT,MAAM,QAAQ,CAAC"}
|