@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.
- package/README.md +252 -23
- package/dist/animator.d.ts +28 -17
- package/dist/animator.d.ts.map +1 -1
- package/dist/create-ssgoi-transition-context.d.ts.map +1 -1
- package/dist/create-transition-callback.d.ts +3 -32
- package/dist/create-transition-callback.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +374 -213
- package/dist/presets/index.cjs +1 -0
- package/dist/presets/index.d.ts +16 -0
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/index.js +35 -0
- package/dist/transition-strategy.d.ts +60 -0
- package/dist/transition-strategy.d.ts.map +1 -0
- package/dist/transition.d.ts +55 -11
- package/dist/transition.d.ts.map +1 -1
- package/dist/transitions/blur.d.ts +5 -1
- package/dist/transitions/blur.d.ts.map +1 -1
- package/dist/transitions/bounce.d.ts +5 -0
- package/dist/transitions/bounce.d.ts.map +1 -1
- package/dist/transitions/fade.d.ts +3 -0
- package/dist/transitions/fade.d.ts.map +1 -1
- package/dist/transitions/fly.d.ts +30 -0
- package/dist/transitions/fly.d.ts.map +1 -0
- package/dist/transitions/index.cjs +1 -1
- package/dist/transitions/index.d.ts +1 -0
- package/dist/transitions/index.d.ts.map +1 -1
- package/dist/transitions/index.js +200 -120
- package/dist/transitions/none.d.ts +3 -0
- package/dist/transitions/none.d.ts.map +1 -1
- package/dist/transitions/rotate.d.ts +6 -0
- package/dist/transitions/rotate.d.ts.map +1 -1
- package/dist/transitions/scale.d.ts +6 -3
- package/dist/transitions/scale.d.ts.map +1 -1
- package/dist/transitions/slide.d.ts +6 -1
- package/dist/transitions/slide.d.ts.map +1 -1
- package/dist/types.d.ts +19 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/utils-8Eptbv7c.cjs +2 -0
- package/dist/utils-DTRMUQW4.js +31 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/view-transitions/drill.d.ts +9 -0
- package/dist/view-transitions/drill.d.ts.map +1 -0
- package/dist/view-transitions/fade.d.ts +3 -1
- package/dist/view-transitions/fade.d.ts.map +1 -1
- package/dist/view-transitions/hero.d.ts.map +1 -1
- package/dist/view-transitions/index.cjs +1 -1
- package/dist/view-transitions/index.d.ts +2 -1
- package/dist/view-transitions/index.d.ts.map +1 -1
- package/dist/view-transitions/index.js +233 -177
- package/dist/view-transitions/scroll.d.ts +8 -0
- package/dist/view-transitions/scroll.d.ts.map +1 -0
- package/package.json +28 -10
- package/dist/utils-BSgyev81.cjs +0 -1
- package/dist/utils-DR41YsAh.js +0 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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 +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 {
|
|
2
|
-
const
|
|
3
|
-
var
|
|
4
|
-
const n = {
|
|
5
|
-
stiffness: ((
|
|
6
|
-
damping: ((
|
|
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: (
|
|
55
|
+
in: (a) => ({
|
|
10
56
|
spring: n,
|
|
11
|
-
|
|
12
|
-
|
|
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: (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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:
|
|
74
|
+
prepare: x,
|
|
75
|
+
onEnd: () => {
|
|
76
|
+
r && r();
|
|
77
|
+
}
|
|
21
78
|
})
|
|
22
79
|
};
|
|
23
80
|
};
|
|
24
|
-
function
|
|
81
|
+
function z(t, n) {
|
|
25
82
|
return t.querySelector(`[data-hero-key="${n}"]`);
|
|
26
83
|
}
|
|
27
84
|
function A(t, n) {
|
|
28
|
-
const
|
|
85
|
+
const s = t.getBoundingClientRect(), e = n.getBoundingClientRect();
|
|
29
86
|
return new DOMRect(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
87
|
+
e.left - s.left,
|
|
88
|
+
e.top - s.top,
|
|
89
|
+
e.width,
|
|
90
|
+
e.height
|
|
34
91
|
);
|
|
35
92
|
}
|
|
36
|
-
const
|
|
37
|
-
var
|
|
93
|
+
const H = (t = {}) => {
|
|
94
|
+
var r, a;
|
|
38
95
|
const n = {
|
|
39
|
-
stiffness: ((
|
|
40
|
-
damping: ((
|
|
41
|
-
},
|
|
42
|
-
let
|
|
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 (
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
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((
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
}) || !
|
|
58
|
-
return
|
|
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 =
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
67
|
-
const u =
|
|
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
|
|
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:
|
|
72
|
-
dx:
|
|
73
|
-
dy:
|
|
74
|
-
dw:
|
|
75
|
-
dh:
|
|
76
|
-
originalTransform:
|
|
77
|
-
originalPosition:
|
|
78
|
-
originalTransformOrigin:
|
|
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
|
|
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:
|
|
90
|
-
|
|
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: (
|
|
94
|
-
p.forEach(({ toEl:
|
|
95
|
-
|
|
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:
|
|
102
|
-
originalTransform:
|
|
159
|
+
toEl: h,
|
|
160
|
+
originalTransform: $,
|
|
103
161
|
originalPosition: u,
|
|
104
|
-
originalTransformOrigin:
|
|
162
|
+
originalTransformOrigin: g,
|
|
163
|
+
originalZIndex: f
|
|
105
164
|
}) => {
|
|
106
|
-
|
|
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 (
|
|
171
|
+
out: async (i) => ({
|
|
113
172
|
onStart: () => {
|
|
114
|
-
|
|
173
|
+
e = i, l && (l(!0), l = null);
|
|
115
174
|
},
|
|
116
175
|
prepare: (o) => {
|
|
117
|
-
|
|
176
|
+
x(o), o.style.opacity = "0";
|
|
118
177
|
}
|
|
119
178
|
})
|
|
120
179
|
};
|
|
121
180
|
};
|
|
122
181
|
function S(t, n) {
|
|
123
|
-
const
|
|
182
|
+
const s = t.getBoundingClientRect(), e = n.getBoundingClientRect();
|
|
124
183
|
return new DOMRect(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
184
|
+
e.left - s.left,
|
|
185
|
+
e.top - s.top,
|
|
186
|
+
e.width,
|
|
187
|
+
e.height
|
|
129
188
|
);
|
|
130
189
|
}
|
|
131
|
-
function
|
|
190
|
+
function C({
|
|
132
191
|
detailRect: t,
|
|
133
192
|
galleryRect: n,
|
|
134
|
-
pageRect:
|
|
135
|
-
scrollOffset:
|
|
136
|
-
},
|
|
137
|
-
const
|
|
138
|
-
return
|
|
139
|
-
const u = 1 -
|
|
140
|
-
|
|
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
|
|
202
|
+
function M({
|
|
144
203
|
galleryRect: t,
|
|
145
204
|
detailRect: n,
|
|
146
|
-
scrollOffset:
|
|
147
|
-
},
|
|
148
|
-
const
|
|
149
|
-
return (
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
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:
|
|
159
|
-
},
|
|
160
|
-
const
|
|
161
|
-
return (
|
|
162
|
-
const
|
|
163
|
-
|
|
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
|
|
225
|
+
function _({
|
|
167
226
|
detailRect: t,
|
|
168
227
|
galleryRect: n,
|
|
169
|
-
pageRect:
|
|
170
|
-
scrollOffset:
|
|
171
|
-
},
|
|
172
|
-
const
|
|
173
|
-
return
|
|
174
|
-
const u = 1 -
|
|
175
|
-
|
|
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
|
|
179
|
-
const
|
|
237
|
+
function U(t, n, s) {
|
|
238
|
+
const e = t.querySelector(
|
|
180
239
|
"[data-pinterest-detail-key]"
|
|
181
|
-
),
|
|
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
|
|
187
|
-
if (!
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
if (!
|
|
191
|
-
|
|
192
|
-
`[data-pinterest-gallery-key="${
|
|
193
|
-
),
|
|
194
|
-
} else if (
|
|
195
|
-
|
|
196
|
-
const
|
|
197
|
-
if (!
|
|
198
|
-
|
|
199
|
-
`[data-pinterest-gallery-key="${
|
|
200
|
-
),
|
|
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 (!
|
|
261
|
+
if (!r || !a)
|
|
203
262
|
return null;
|
|
204
|
-
const o = S(
|
|
205
|
-
return
|
|
206
|
-
inAnimation:
|
|
207
|
-
{ detailRect:
|
|
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:
|
|
211
|
-
{ galleryRect: o, detailRect:
|
|
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:
|
|
275
|
+
{ galleryRect: o, detailRect: c, scrollOffset: s },
|
|
217
276
|
n
|
|
218
277
|
),
|
|
219
|
-
outAnimation:
|
|
220
|
-
{ detailRect:
|
|
278
|
+
outAnimation: _(
|
|
279
|
+
{ detailRect: c, galleryRect: o, pageRect: y, scrollOffset: s },
|
|
221
280
|
t
|
|
222
281
|
)
|
|
223
282
|
};
|
|
224
283
|
}
|
|
225
|
-
const
|
|
226
|
-
var
|
|
284
|
+
const N = (t = {}) => {
|
|
285
|
+
var a, i;
|
|
227
286
|
const n = {
|
|
228
|
-
stiffness: ((
|
|
229
|
-
damping: ((
|
|
230
|
-
},
|
|
231
|
-
let
|
|
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:
|
|
234
|
-
const
|
|
292
|
+
in: async (o, { scrollOffset: c }) => {
|
|
293
|
+
const y = o;
|
|
235
294
|
return !await new Promise((p) => {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
},
|
|
239
|
-
}) || !
|
|
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
|
-
}) : (
|
|
302
|
+
}) : (r = U(e, y, c), r ? (e = null, {
|
|
244
303
|
spring: n,
|
|
245
304
|
tick: (p) => {
|
|
246
|
-
|
|
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
|
-
|
|
316
|
+
e = o, l && (l(!0), l = null);
|
|
258
317
|
},
|
|
259
|
-
prepare: (
|
|
260
|
-
|
|
318
|
+
prepare: (c) => {
|
|
319
|
+
x(c), c.style.zIndex = "-1";
|
|
261
320
|
},
|
|
262
|
-
tick: (
|
|
263
|
-
|
|
321
|
+
tick: (c) => {
|
|
322
|
+
r && r.outAnimation(c);
|
|
264
323
|
}
|
|
265
324
|
})
|
|
266
325
|
};
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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: (
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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"}
|