@ssgoi/core 0.0.3 → 2.0.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-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 +310 -195
- 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 +7 -3
- package/dist/transition.d.ts.map +1 -1
- package/dist/transitions/blur.d.ts +2 -1
- package/dist/transitions/blur.d.ts.map +1 -1
- package/dist/transitions/bounce.d.ts +2 -0
- package/dist/transitions/bounce.d.ts.map +1 -1
- package/dist/transitions/fly.d.ts +27 -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 +175 -111
- package/dist/transitions/rotate.d.ts +3 -0
- package/dist/transitions/rotate.d.ts.map +1 -1
- package/dist/transitions/scale.d.ts +3 -3
- package/dist/transitions/scale.d.ts.map +1 -1
- package/dist/transitions/slide.d.ts +3 -1
- package/dist/transitions/slide.d.ts.map +1 -1
- package/dist/types.d.ts +8 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/view-transitions/index.cjs +1 -1
- package/dist/view-transitions/index.d.ts +1 -1
- package/dist/view-transitions/index.js +117 -126
- package/dist/view-transitions/scroll.d.ts +8 -0
- package/dist/view-transitions/scroll.d.ts.map +1 -0
- package/package.json +21 -4
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { TransitionConfig } from './types';
|
|
2
|
+
import { Animator } from './animator';
|
|
3
|
+
export declare const TRANSITION_STRATEGY: unique symbol;
|
|
4
|
+
export interface StrategyContext<TAnimationValue = number> {
|
|
5
|
+
currentAnimation: {
|
|
6
|
+
animator: Animator<TAnimationValue>;
|
|
7
|
+
direction: "in" | "out";
|
|
8
|
+
} | null;
|
|
9
|
+
}
|
|
10
|
+
export interface AnimationSetup<TAnimationValue = number> {
|
|
11
|
+
config?: TransitionConfig<TAnimationValue>;
|
|
12
|
+
state: {
|
|
13
|
+
position: TAnimationValue;
|
|
14
|
+
velocity: TAnimationValue extends number ? number : Record<string, number>;
|
|
15
|
+
};
|
|
16
|
+
from: TAnimationValue;
|
|
17
|
+
to: TAnimationValue;
|
|
18
|
+
direction: "forward" | "backward";
|
|
19
|
+
}
|
|
20
|
+
export interface TransitionConfigs<TAnimationValue = number> {
|
|
21
|
+
in?: Promise<TransitionConfig<TAnimationValue>>;
|
|
22
|
+
out?: Promise<TransitionConfig<TAnimationValue>>;
|
|
23
|
+
}
|
|
24
|
+
export interface TransitionStrategy<TAnimationValue = number> {
|
|
25
|
+
runIn: (configs: TransitionConfigs<TAnimationValue>) => Promise<AnimationSetup<TAnimationValue>>;
|
|
26
|
+
runOut: (configs: TransitionConfigs<TAnimationValue>) => Promise<AnimationSetup<TAnimationValue>>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a transition callback that can be used with framework-specific implementations
|
|
30
|
+
* This is the core logic that frameworks can wrap with their own APIs
|
|
31
|
+
*
|
|
32
|
+
* UX Animation Behavior - 4 Main Scenarios:
|
|
33
|
+
*
|
|
34
|
+
* 1. No animation running + IN trigger:
|
|
35
|
+
* - Start entrance animation (0 → 1)
|
|
36
|
+
* - Return cleanup function for exit
|
|
37
|
+
*
|
|
38
|
+
* 2. No animation running + OUT trigger:
|
|
39
|
+
* - Clone element, start exit animation (1 → 0)
|
|
40
|
+
* - Remove clone when complete
|
|
41
|
+
*
|
|
42
|
+
* 3. IN animation running + OUT trigger:
|
|
43
|
+
* - Stop current IN animation (DOM is disappearing)
|
|
44
|
+
* - Clone element for exit animation
|
|
45
|
+
* - Create REVERSED IN animation (not OUT animation) with current state
|
|
46
|
+
* - This gives natural backward motion instead of jumping to OUT definition
|
|
47
|
+
*
|
|
48
|
+
* 4. OUT animation running + IN trigger:
|
|
49
|
+
* - Stop current OUT animation (cleanup any cloned elements)
|
|
50
|
+
* - Create REVERSED OUT animation (not IN animation) with current state
|
|
51
|
+
* - This gives natural backward motion instead of jumping to IN definition
|
|
52
|
+
* - Switch to entrance mode
|
|
53
|
+
*
|
|
54
|
+
* Closure Structure:
|
|
55
|
+
* - Outer function: Returns entrance callback
|
|
56
|
+
* - Inner function (entrance callback): Returns cleanup callback (exit)
|
|
57
|
+
* - Cleanup callback: Handles exit transitions
|
|
58
|
+
*/
|
|
59
|
+
export declare const createDefaultStrategy: <TAnimationValue = number>(context: StrategyContext<TAnimationValue>) => TransitionStrategy<TAnimationValue>;
|
|
60
|
+
//# sourceMappingURL=transition-strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transition-strategy.d.ts","sourceRoot":"","sources":["../src/lib/transition-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,eAAO,MAAM,mBAAmB,eAAoC,CAAC;AAErE,MAAM,WAAW,eAAe,CAAC,eAAe,GAAG,MAAM;IAEvD,gBAAgB,EAAE;QAAE,QAAQ,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;QAAC,SAAS,EAAE,IAAI,GAAG,KAAK,CAAA;KAAE,GAAG,IAAI,CAAC;CAC3F;AAED,MAAM,WAAW,cAAc,CAAC,eAAe,GAAG,MAAM;IACtD,MAAM,CAAC,EAAE,gBAAgB,CAAC,eAAe,CAAC,CAAC;IAC3C,KAAK,EAAE;QAAE,QAAQ,EAAE,eAAe,CAAC;QAAC,QAAQ,EAAE,eAAe,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;IACjH,IAAI,EAAE,eAAe,CAAC;IACtB,EAAE,EAAE,eAAe,CAAC;IACpB,SAAS,EAAE,SAAS,GAAG,UAAU,CAAC;CACnC;AAED,MAAM,WAAW,iBAAiB,CAAC,eAAe,GAAG,MAAM;IACzD,EAAE,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,CAAC;IAChD,GAAG,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,CAAC;CAClD;AAED,MAAM,WAAW,kBAAkB,CAAC,eAAe,GAAG,MAAM;IAC1D,KAAK,EAAE,CAAC,OAAO,EAAE,iBAAiB,CAAC,eAAe,CAAC,KAAK,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC;IACjG,MAAM,EAAE,CAAC,OAAO,EAAE,iBAAiB,CAAC,eAAe,CAAC,KAAK,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC;CACnG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,eAAO,MAAM,qBAAqB,GAAI,eAAe,GAAG,MAAM,EAC5D,SAAS,eAAe,CAAC,eAAe,CAAC,KACxC,kBAAkB,CAAC,eAAe,CAmGpC,CAAC"}
|
package/dist/transition.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StrategyContext, TRANSITION_STRATEGY, TransitionStrategy } from './transition-strategy';
|
|
1
2
|
import { Transition, TransitionCallback } from './types';
|
|
2
3
|
/**
|
|
3
4
|
* Key type for transitions - can be string or symbol
|
|
@@ -6,11 +7,14 @@ type TransitionKey = string | symbol;
|
|
|
6
7
|
/**
|
|
7
8
|
* Framework-agnostic transition function that can be used as a ref
|
|
8
9
|
* Usage: <div ref={transition({ key: 'fade', in, out })} />
|
|
10
|
+
*
|
|
11
|
+
* @template TAnimationValue - The type of value being animated (number | object)
|
|
9
12
|
*/
|
|
10
|
-
export declare function transition(options: {
|
|
13
|
+
export declare function transition<TAnimationValue = number>(options: {
|
|
11
14
|
key: TransitionKey;
|
|
12
|
-
in?: Transition["in"];
|
|
13
|
-
out?: Transition["out"];
|
|
15
|
+
in?: Transition<undefined, TAnimationValue>["in"];
|
|
16
|
+
out?: Transition<undefined, TAnimationValue>["out"];
|
|
17
|
+
[TRANSITION_STRATEGY]?: (context: StrategyContext<TAnimationValue>) => TransitionStrategy<TAnimationValue>;
|
|
14
18
|
}): TransitionCallback;
|
|
15
19
|
export {};
|
|
16
20
|
//# sourceMappingURL=transition.d.ts.map
|
package/dist/transition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../src/lib/transition.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE9D;;GAEG;AACH,KAAK,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"transition.d.ts","sourceRoot":"","sources":["../src/lib/transition.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE9D;;GAEG;AACH,KAAK,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;AAyDrC;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,eAAe,GAAG,MAAM,EAAE,OAAO,EAAE;IAC5D,GAAG,EAAE,aAAa,CAAC;IACnB,EAAE,CAAC,EAAE,UAAU,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC;IAClD,GAAG,CAAC,EAAE,UAAU,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,eAAe,CAAC,KAAK,kBAAkB,CAAC,eAAe,CAAC,CAAC;CAC5G,GAAG,kBAAkB,CAMrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blur.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/blur.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"blur.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/blur.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,IAAI,GAAI,UAAS,WAAgB;kBAc5B,WAAW;;wBAnBb,MAAM;sBACR,MAAM;;yBAoBG,MAAM;;mBAmBV,WAAW;;wBAxCd,MAAM;sBACR,MAAM;;yBAyCG,MAAM;;CAoB5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bounce.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/bounce.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,MAAM,GAAI,UAAS,aAAkB;
|
|
1
|
+
{"version":3,"file":"bounce.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/bounce.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,MAAM,GAAI,UAAS,aAAkB;kBAWhC,WAAW;;wBAhBb,MAAM;sBACR,MAAM;;yBAiBG,MAAM;;mBA0BV,WAAW;;wBA5Cd,MAAM;sBACR,MAAM;;yBA6CG,MAAM;;CA2B5B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface FlyOptions {
|
|
2
|
+
x?: number | string;
|
|
3
|
+
y?: number | string;
|
|
4
|
+
opacity?: number;
|
|
5
|
+
spring?: {
|
|
6
|
+
stiffness?: number;
|
|
7
|
+
damping?: number;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare const fly: (options?: FlyOptions) => {
|
|
11
|
+
in: (element: HTMLElement) => {
|
|
12
|
+
spring: {
|
|
13
|
+
stiffness?: number;
|
|
14
|
+
damping?: number;
|
|
15
|
+
};
|
|
16
|
+
tick: (progress: number) => void;
|
|
17
|
+
};
|
|
18
|
+
out: (element: HTMLElement) => {
|
|
19
|
+
spring: {
|
|
20
|
+
stiffness?: number;
|
|
21
|
+
damping?: number;
|
|
22
|
+
};
|
|
23
|
+
tick: (progress: number) => void;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=fly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fly.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/fly.ts"],"names":[],"mappings":"AAAA,UAAU,UAAU;IAClB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,GAAG,GAAI,UAAS,UAAe;kBAiB1B,WAAW;;wBAtBb,MAAM;sBACR,MAAM;;yBAuBG,MAAM;;mBAQV,WAAW;;wBAhCd,MAAM;sBACR,MAAM;;yBAiCG,MAAM;;CAS5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=(p={})=>{const{from:n=0,to:s=1,spring:r={stiffness:300,damping:30}}=p;return{in:u=>({spring:r,tick:l=>{const c=n+(s-n)*l;u.style.opacity=c.toString()}}),out:u=>({spring:r,tick:l=>{const c=n+(s-n)*l;u.style.opacity=c.toString()}})}},b=(p={})=>{const{start:n=0,opacity:s=0,axis:r="both",spring:u={stiffness:300,damping:30}}=p,l=c=>{switch(r){case"x":return`scaleX(${c})`;case"y":return`scaleY(${c})`;case"both":default:return`scale(${c})`}};return{in:c=>({spring:u,tick:t=>{const e=n+(1-n)*t;c.style.transform=l(e),c.style.opacity=(s+(1-s)*t).toString()}}),out:c=>({spring:u,tick:t=>{const e=n+(1-n)*t;c.style.transform=l(e),c.style.opacity=(s+(1-s)*t).toString()}})}},m=(p={})=>{const{direction:n,distance:s=100,opacity:r=0,fade:u=!0,axis:l,spring:c={stiffness:400,damping:35}}=p,e=n||(l==="x"?"left":l==="y"?"up":"left"),o=a=>typeof a=="number"?`${a}px`:a,f=a=>{const i=1-a,y=typeof s=="number"?i*s:`calc(${o(s)} * ${i})`;switch(e){case"left":return typeof s=="number"?`translateX(${-y}px)`:`translateX(calc(-1 * ${y}))`;case"right":return typeof s=="number"?`translateX(${y}px)`:`translateX(${y})`;case"up":return typeof s=="number"?`translateY(${-y}px)`:`translateY(calc(-1 * ${y}))`;case"down":return typeof s=="number"?`translateY(${y}px)`:`translateY(${y})`}};return{in:a=>({spring:c,tick:i=>{a.style.transform=f(i),u&&(a.style.opacity=(r+(1-r)*i).toString())}}),out:a=>({spring:c,tick:i=>{a.style.transform=f(i),u&&(a.style.opacity=(r+(1-r)*i).toString())}})}},d=(p={})=>{const{degrees:n=360,clockwise:s=!0,scale:r=!1,fade:u=!0,origin:l="center",axis:c="2d",perspective:t=800,spring:e={stiffness:500,damping:25}}=p,o=s?n:-n,f=a=>{const i=(1-a)*o;switch(c){case"x":return`perspective(${t}px) rotateX(${i}deg)`;case"y":return`perspective(${t}px) rotateY(${i}deg)`;case"z":return`rotateZ(${i}deg)`;case"2d":default:return`rotate(${i}deg)`}};return{in:a=>({spring:e,tick:i=>{const y=[f(i)];r&&y.push(`scale(${i})`),a.style.transform=y.join(" "),a.style.transformOrigin=l,u&&(a.style.opacity=i.toString())}}),out:a=>({spring:e,tick:i=>{const y=[f(i)];r&&y.push(`scale(${i})`),a.style.transform=y.join(" "),a.style.transformOrigin=l,u&&(a.style.opacity=i.toString())}})}},g=(p={})=>{const{height:n=20,intensity:s=1,scale:r=!0,fade:u=!0,direction:l="up",spring:c={stiffness:800,damping:15}}=p;return{in:t=>({spring:c,tick:e=>{const o=[],f=Math.sin(e*Math.PI*(1+s)),a=1-e,i=f*n*a;if(l==="up"?o.push(`translateY(${-Math.abs(i)}px)`):o.push(`translateY(${Math.abs(i)}px)`),r){const y=.8+e*.2+f*.05*a;o.push(`scale(${y})`)}t.style.transform=o.join(" "),u&&(t.style.opacity=e.toString())}}),out:t=>({spring:c,tick:e=>{const o=[],f=Math.sin(e*Math.PI*(1+s)),a=1-e,i=f*n*a;if(l==="up"?o.push(`translateY(${-Math.abs(i)}px)`):o.push(`translateY(${Math.abs(i)}px)`),r){const y=.8+e*.2+f*.05*a;o.push(`scale(${y})`)}t.style.transform=o.join(" "),u&&(t.style.opacity=e.toString())}})}},x=(p={})=>{const{amount:n=10,opacity:s=0,scale:r=!1,fade:u=!0,spring:l={stiffness:300,damping:30}}=p,c=t=>typeof t=="number"?`${t}px`:t;return{in:t=>({spring:l,tick:e=>{const o=1-e,f=typeof n=="number"?o*n:`calc(${c(n)} * ${o})`;t.style.filter=typeof n=="number"?`blur(${f}px)`:`blur(${f})`,r&&(t.style.transform=`scale(${.8+e*.2})`),u&&(t.style.opacity=(s+(1-s)*e).toString())}}),out:t=>({spring:l,tick:e=>{const o=1-e,f=typeof n=="number"?o*n:`calc(${c(n)} * ${o})`;t.style.filter=typeof n=="number"?`blur(${f}px)`:`blur(${f})`,r&&(t.style.transform=`scale(${.8+e*.2})`),u&&(t.style.opacity=(s+(1-s)*e).toString())}})}},h=(p={})=>{const{x:n=0,y:s=-100,opacity:r=0,spring:u={stiffness:400,damping:35}}=p,l=t=>typeof t=="number"?`${t}px`:t,c=t=>typeof t=="number"?`${t}px`:t;return{in:t=>({spring:u,tick:e=>{const o=typeof n=="number"?(1-e)*n:`calc(${l(n)} * ${1-e})`,f=typeof s=="number"?(1-e)*s:`calc(${c(s)} * ${1-e})`;t.style.transform=`translate(${typeof n=="number"?o+"px":o}, ${typeof s=="number"?f+"px":f})`,t.style.opacity=(r+(1-r)*e).toString()}}),out:t=>({spring:u,tick:e=>{const o=typeof n=="number"?(1-e)*n:`calc(${l(n)} * ${1-e})`,f=typeof s=="number"?(1-e)*s:`calc(${c(s)} * ${1-e})`;t.style.transform=`translate(${typeof n=="number"?o+"px":o}, ${typeof s=="number"?f+"px":f})`,t.style.opacity=(r+(1-r)*e).toString()}})}},k=(p={})=>{const{spring:n={stiffness:1e3,damping:100}}=p;return{in:s=>({spring:n,tick:r=>{}}),out:s=>({spring:n,tick:r=>{}})}};exports.blur=x;exports.bounce=g;exports.fade=$;exports.fly=h;exports.none=k;exports.rotate=d;exports.scale=b;exports.slide=m;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC"}
|
|
@@ -1,173 +1,237 @@
|
|
|
1
|
-
const
|
|
1
|
+
const $ = (p = {}) => {
|
|
2
2
|
const {
|
|
3
|
-
from:
|
|
4
|
-
to:
|
|
5
|
-
spring:
|
|
6
|
-
} =
|
|
3
|
+
from: n = 0,
|
|
4
|
+
to: e = 1,
|
|
5
|
+
spring: r = { stiffness: 300, damping: 30 }
|
|
6
|
+
} = p;
|
|
7
7
|
return {
|
|
8
|
-
in: (
|
|
9
|
-
spring:
|
|
10
|
-
tick: (
|
|
11
|
-
const
|
|
12
|
-
|
|
8
|
+
in: (u) => ({
|
|
9
|
+
spring: r,
|
|
10
|
+
tick: (l) => {
|
|
11
|
+
const c = n + (e - n) * l;
|
|
12
|
+
u.style.opacity = c.toString();
|
|
13
13
|
}
|
|
14
14
|
}),
|
|
15
|
-
out: (
|
|
16
|
-
spring:
|
|
17
|
-
tick: (
|
|
18
|
-
const
|
|
19
|
-
|
|
15
|
+
out: (u) => ({
|
|
16
|
+
spring: r,
|
|
17
|
+
tick: (l) => {
|
|
18
|
+
const c = n + (e - n) * l;
|
|
19
|
+
u.style.opacity = c.toString();
|
|
20
20
|
}
|
|
21
21
|
})
|
|
22
22
|
};
|
|
23
|
-
},
|
|
23
|
+
}, m = (p = {}) => {
|
|
24
24
|
const {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
start: n = 0,
|
|
26
|
+
opacity: e = 0,
|
|
27
|
+
axis: r = "both",
|
|
28
|
+
spring: u = { stiffness: 300, damping: 30 }
|
|
29
|
+
} = p, l = (c) => {
|
|
30
|
+
switch (r) {
|
|
31
|
+
case "x":
|
|
32
|
+
return `scaleX(${c})`;
|
|
33
|
+
case "y":
|
|
34
|
+
return `scaleY(${c})`;
|
|
35
|
+
case "both":
|
|
36
|
+
default:
|
|
37
|
+
return `scale(${c})`;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
29
40
|
return {
|
|
30
|
-
in: (
|
|
31
|
-
spring:
|
|
32
|
-
tick: (
|
|
33
|
-
const
|
|
34
|
-
|
|
41
|
+
in: (c) => ({
|
|
42
|
+
spring: u,
|
|
43
|
+
tick: (t) => {
|
|
44
|
+
const s = n + (1 - n) * t;
|
|
45
|
+
c.style.transform = l(s), c.style.opacity = (e + (1 - e) * t).toString();
|
|
35
46
|
}
|
|
36
47
|
}),
|
|
37
|
-
out: (
|
|
38
|
-
spring:
|
|
39
|
-
tick: (
|
|
40
|
-
const
|
|
41
|
-
|
|
48
|
+
out: (c) => ({
|
|
49
|
+
spring: u,
|
|
50
|
+
tick: (t) => {
|
|
51
|
+
const s = n + (1 - n) * t;
|
|
52
|
+
c.style.transform = l(s), c.style.opacity = (e + (1 - e) * t).toString();
|
|
42
53
|
}
|
|
43
54
|
})
|
|
44
55
|
};
|
|
45
|
-
},
|
|
56
|
+
}, b = (p = {}) => {
|
|
46
57
|
const {
|
|
47
|
-
direction:
|
|
48
|
-
distance:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
direction: n,
|
|
59
|
+
distance: e = 100,
|
|
60
|
+
opacity: r = 0,
|
|
61
|
+
fade: u = !0,
|
|
62
|
+
axis: l,
|
|
63
|
+
spring: c = { stiffness: 400, damping: 35 }
|
|
64
|
+
} = p, s = n || (l === "x" ? "left" : l === "y" ? "up" : "left"), o = (a) => typeof a == "number" ? `${a}px` : a, f = (a) => {
|
|
65
|
+
const i = 1 - a, y = typeof e == "number" ? i * e : `calc(${o(e)} * ${i})`;
|
|
66
|
+
switch (s) {
|
|
54
67
|
case "left":
|
|
55
|
-
return `translateX(${-
|
|
68
|
+
return typeof e == "number" ? `translateX(${-y}px)` : `translateX(calc(-1 * ${y}))`;
|
|
56
69
|
case "right":
|
|
57
|
-
return `translateX(${
|
|
70
|
+
return typeof e == "number" ? `translateX(${y}px)` : `translateX(${y})`;
|
|
58
71
|
case "up":
|
|
59
|
-
return `translateY(${-
|
|
72
|
+
return typeof e == "number" ? `translateY(${-y}px)` : `translateY(calc(-1 * ${y}))`;
|
|
60
73
|
case "down":
|
|
61
|
-
return `translateY(${
|
|
74
|
+
return typeof e == "number" ? `translateY(${y}px)` : `translateY(${y})`;
|
|
62
75
|
}
|
|
63
76
|
};
|
|
64
77
|
return {
|
|
65
|
-
in: (
|
|
66
|
-
spring:
|
|
67
|
-
tick: (
|
|
68
|
-
|
|
78
|
+
in: (a) => ({
|
|
79
|
+
spring: c,
|
|
80
|
+
tick: (i) => {
|
|
81
|
+
a.style.transform = f(i), u && (a.style.opacity = (r + (1 - r) * i).toString());
|
|
69
82
|
}
|
|
70
83
|
}),
|
|
71
|
-
out: (
|
|
72
|
-
spring:
|
|
73
|
-
tick: (
|
|
74
|
-
|
|
84
|
+
out: (a) => ({
|
|
85
|
+
spring: c,
|
|
86
|
+
tick: (i) => {
|
|
87
|
+
a.style.transform = f(i), u && (a.style.opacity = (r + (1 - r) * i).toString());
|
|
75
88
|
}
|
|
76
89
|
})
|
|
77
90
|
};
|
|
78
|
-
},
|
|
91
|
+
}, x = (p = {}) => {
|
|
79
92
|
const {
|
|
80
|
-
degrees:
|
|
81
|
-
clockwise:
|
|
82
|
-
scale:
|
|
83
|
-
fade:
|
|
93
|
+
degrees: n = 360,
|
|
94
|
+
clockwise: e = !0,
|
|
95
|
+
scale: r = !1,
|
|
96
|
+
fade: u = !0,
|
|
97
|
+
origin: l = "center",
|
|
98
|
+
axis: c = "2d",
|
|
99
|
+
perspective: t = 800,
|
|
84
100
|
spring: s = { stiffness: 500, damping: 25 }
|
|
85
|
-
} =
|
|
101
|
+
} = p, o = e ? n : -n, f = (a) => {
|
|
102
|
+
const i = (1 - a) * o;
|
|
103
|
+
switch (c) {
|
|
104
|
+
case "x":
|
|
105
|
+
return `perspective(${t}px) rotateX(${i}deg)`;
|
|
106
|
+
case "y":
|
|
107
|
+
return `perspective(${t}px) rotateY(${i}deg)`;
|
|
108
|
+
case "z":
|
|
109
|
+
return `rotateZ(${i}deg)`;
|
|
110
|
+
case "2d":
|
|
111
|
+
default:
|
|
112
|
+
return `rotate(${i}deg)`;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
86
115
|
return {
|
|
87
|
-
in: (
|
|
116
|
+
in: (a) => ({
|
|
88
117
|
spring: s,
|
|
89
|
-
tick: (
|
|
90
|
-
const
|
|
91
|
-
|
|
118
|
+
tick: (i) => {
|
|
119
|
+
const y = [f(i)];
|
|
120
|
+
r && y.push(`scale(${i})`), a.style.transform = y.join(" "), a.style.transformOrigin = l, u && (a.style.opacity = i.toString());
|
|
92
121
|
}
|
|
93
122
|
}),
|
|
94
|
-
out: (
|
|
123
|
+
out: (a) => ({
|
|
95
124
|
spring: s,
|
|
96
|
-
tick: (
|
|
97
|
-
const
|
|
98
|
-
|
|
125
|
+
tick: (i) => {
|
|
126
|
+
const y = [f(i)];
|
|
127
|
+
r && y.push(`scale(${i})`), a.style.transform = y.join(" "), a.style.transformOrigin = l, u && (a.style.opacity = i.toString());
|
|
99
128
|
}
|
|
100
129
|
})
|
|
101
130
|
};
|
|
102
|
-
}, d = (
|
|
131
|
+
}, d = (p = {}) => {
|
|
103
132
|
const {
|
|
104
|
-
height:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
133
|
+
height: n = 20,
|
|
134
|
+
intensity: e = 1,
|
|
135
|
+
scale: r = !0,
|
|
136
|
+
fade: u = !0,
|
|
137
|
+
direction: l = "up",
|
|
138
|
+
spring: c = { stiffness: 800, damping: 15 }
|
|
139
|
+
} = p;
|
|
109
140
|
return {
|
|
110
|
-
in: (
|
|
111
|
-
spring:
|
|
112
|
-
tick: (
|
|
113
|
-
const
|
|
114
|
-
|
|
141
|
+
in: (t) => ({
|
|
142
|
+
spring: c,
|
|
143
|
+
tick: (s) => {
|
|
144
|
+
const o = [], f = Math.sin(s * Math.PI * (1 + e)), a = 1 - s, i = f * n * a;
|
|
145
|
+
if (l === "up" ? o.push(`translateY(${-Math.abs(i)}px)`) : o.push(`translateY(${Math.abs(i)}px)`), r) {
|
|
146
|
+
const y = 0.8 + s * 0.2 + f * 0.05 * a;
|
|
147
|
+
o.push(`scale(${y})`);
|
|
148
|
+
}
|
|
149
|
+
t.style.transform = o.join(" "), u && (t.style.opacity = s.toString());
|
|
115
150
|
}
|
|
116
151
|
}),
|
|
117
|
-
out: (
|
|
118
|
-
spring:
|
|
119
|
-
tick: (
|
|
120
|
-
const
|
|
121
|
-
|
|
152
|
+
out: (t) => ({
|
|
153
|
+
spring: c,
|
|
154
|
+
tick: (s) => {
|
|
155
|
+
const o = [], f = Math.sin(s * Math.PI * (1 + e)), a = 1 - s, i = f * n * a;
|
|
156
|
+
if (l === "up" ? o.push(`translateY(${-Math.abs(i)}px)`) : o.push(`translateY(${Math.abs(i)}px)`), r) {
|
|
157
|
+
const y = 0.8 + s * 0.2 + f * 0.05 * a;
|
|
158
|
+
o.push(`scale(${y})`);
|
|
159
|
+
}
|
|
160
|
+
t.style.transform = o.join(" "), u && (t.style.opacity = s.toString());
|
|
122
161
|
}
|
|
123
162
|
})
|
|
124
163
|
};
|
|
125
|
-
},
|
|
164
|
+
}, g = (p = {}) => {
|
|
126
165
|
const {
|
|
127
|
-
amount:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
166
|
+
amount: n = 10,
|
|
167
|
+
opacity: e = 0,
|
|
168
|
+
scale: r = !1,
|
|
169
|
+
fade: u = !0,
|
|
170
|
+
spring: l = { stiffness: 300, damping: 30 }
|
|
171
|
+
} = p, c = (t) => typeof t == "number" ? `${t}px` : t;
|
|
132
172
|
return {
|
|
133
|
-
in: (
|
|
134
|
-
spring:
|
|
135
|
-
tick: (
|
|
136
|
-
const
|
|
137
|
-
|
|
173
|
+
in: (t) => ({
|
|
174
|
+
spring: l,
|
|
175
|
+
tick: (s) => {
|
|
176
|
+
const o = 1 - s, f = typeof n == "number" ? o * n : `calc(${c(n)} * ${o})`;
|
|
177
|
+
t.style.filter = typeof n == "number" ? `blur(${f}px)` : `blur(${f})`, r && (t.style.transform = `scale(${0.8 + s * 0.2})`), u && (t.style.opacity = (e + (1 - e) * s).toString());
|
|
138
178
|
}
|
|
139
179
|
}),
|
|
140
|
-
out: (
|
|
141
|
-
spring:
|
|
142
|
-
tick: (
|
|
143
|
-
const
|
|
144
|
-
|
|
180
|
+
out: (t) => ({
|
|
181
|
+
spring: l,
|
|
182
|
+
tick: (s) => {
|
|
183
|
+
const o = 1 - s, f = typeof n == "number" ? o * n : `calc(${c(n)} * ${o})`;
|
|
184
|
+
t.style.filter = typeof n == "number" ? `blur(${f}px)` : `blur(${f})`, r && (t.style.transform = `scale(${0.8 + s * 0.2})`), u && (t.style.opacity = (e + (1 - e) * s).toString());
|
|
145
185
|
}
|
|
146
186
|
})
|
|
147
187
|
};
|
|
148
|
-
},
|
|
188
|
+
}, h = (p = {}) => {
|
|
149
189
|
const {
|
|
150
|
-
|
|
151
|
-
|
|
190
|
+
x: n = 0,
|
|
191
|
+
y: e = -100,
|
|
192
|
+
opacity: r = 0,
|
|
193
|
+
spring: u = { stiffness: 400, damping: 35 }
|
|
194
|
+
} = p, l = (t) => typeof t == "number" ? `${t}px` : t, c = (t) => typeof t == "number" ? `${t}px` : t;
|
|
152
195
|
return {
|
|
153
|
-
in: (
|
|
154
|
-
spring:
|
|
155
|
-
tick: (
|
|
196
|
+
in: (t) => ({
|
|
197
|
+
spring: u,
|
|
198
|
+
tick: (s) => {
|
|
199
|
+
const o = typeof n == "number" ? (1 - s) * n : `calc(${l(n)} * ${1 - s})`, f = typeof e == "number" ? (1 - s) * e : `calc(${c(e)} * ${1 - s})`;
|
|
200
|
+
t.style.transform = `translate(${typeof n == "number" ? o + "px" : o}, ${typeof e == "number" ? f + "px" : f})`, t.style.opacity = (r + (1 - r) * s).toString();
|
|
156
201
|
}
|
|
157
202
|
}),
|
|
158
|
-
out: (
|
|
159
|
-
spring:
|
|
160
|
-
tick: (
|
|
203
|
+
out: (t) => ({
|
|
204
|
+
spring: u,
|
|
205
|
+
tick: (s) => {
|
|
206
|
+
const o = typeof n == "number" ? (1 - s) * n : `calc(${l(n)} * ${1 - s})`, f = typeof e == "number" ? (1 - s) * e : `calc(${c(e)} * ${1 - s})`;
|
|
207
|
+
t.style.transform = `translate(${typeof n == "number" ? o + "px" : o}, ${typeof e == "number" ? f + "px" : f})`, t.style.opacity = (r + (1 - r) * s).toString();
|
|
208
|
+
}
|
|
209
|
+
})
|
|
210
|
+
};
|
|
211
|
+
}, k = (p = {}) => {
|
|
212
|
+
const {
|
|
213
|
+
spring: n = { stiffness: 1e3, damping: 100 }
|
|
214
|
+
} = p;
|
|
215
|
+
return {
|
|
216
|
+
in: (e) => ({
|
|
217
|
+
spring: n,
|
|
218
|
+
tick: (r) => {
|
|
219
|
+
}
|
|
220
|
+
}),
|
|
221
|
+
out: (e) => ({
|
|
222
|
+
spring: n,
|
|
223
|
+
tick: (r) => {
|
|
161
224
|
}
|
|
162
225
|
})
|
|
163
226
|
};
|
|
164
227
|
};
|
|
165
228
|
export {
|
|
166
|
-
|
|
229
|
+
g as blur,
|
|
167
230
|
d as bounce,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
231
|
+
$ as fade,
|
|
232
|
+
h as fly,
|
|
233
|
+
k as none,
|
|
234
|
+
x as rotate,
|
|
235
|
+
m as scale,
|
|
236
|
+
b as slide
|
|
173
237
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotate.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/rotate.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,MAAM,GAAI,UAAS,aAAkB;
|
|
1
|
+
{"version":3,"file":"rotate.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/rotate.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,MAAM,GAAI,UAAS,aAAkB;kBA8BhC,WAAW;;wBAnCb,MAAM;sBACR,MAAM;;yBAoCG,MAAM;;mBAeV,WAAW;;wBApDd,MAAM;sBACR,MAAM;;yBAqDG,MAAM;;CAgB5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scale.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/scale.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,
|
|
1
|
+
{"version":3,"file":"scale.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/scale.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,KAAK,GAAI,UAAS,YAAiB;kBAqB9B,WAAW;;wBA1Bb,MAAM;sBACR,MAAM;;yBA2BG,MAAM;;mBAMV,WAAW;;wBAlCd,MAAM;sBACR,MAAM;;yBAmCG,MAAM;;CAO5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slide.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/slide.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"slide.d.ts","sourceRoot":"","sources":["../../src/lib/transitions/slide.ts"],"names":[],"mappings":"AAAA,UAAU,YAAY;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC;IAC7C,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;IACjB,MAAM,CAAC,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,KAAK,GAAI,UAAS,YAAiB;kBAmD9B,WAAW;;wBAxDb,MAAM;sBACR,MAAM;;yBAyDG,MAAM;;mBAOV,WAAW;;wBAjEd,MAAM;sBACR,MAAM;;yBAkEG,MAAM;;CAQ5B,CAAC"}
|