@stellix-agency/motion 1.0.1 → 1.0.2
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 +17 -5
- package/dist/chunk-YEOCNWCQ.js +0 -0
- package/dist/index.d.ts +11 -219
- package/dist/index.js +1 -1
- package/dist/jsx.d.ts +221 -0
- package/dist/jsx.js +1 -0
- package/package.json +23 -3
package/README.md
CHANGED
|
@@ -9,7 +9,8 @@ An intuitive and powerful GSAP wrapper for creating stunning animations with eas
|
|
|
9
9
|
📜 **Scroll Animations** - Easy ScrollTrigger integration
|
|
10
10
|
🎨 **Rich Presets** - Common animation patterns out of the box
|
|
11
11
|
🔧 **Utility Functions** - Stagger, batch, parallax, and more
|
|
12
|
-
⚡ **Lightweight** - Minimal wrapper over GSAP's powerful engine
|
|
12
|
+
⚡ **Lightweight** - Minimal wrapper over GSAP's powerful engine
|
|
13
|
+
🔥 **Auto Types** - No manual type declarations needed (v1.0.1+)
|
|
13
14
|
|
|
14
15
|
## Installation
|
|
15
16
|
|
|
@@ -17,6 +18,8 @@ An intuitive and powerful GSAP wrapper for creating stunning animations with eas
|
|
|
17
18
|
npm install @stellix-agency/motion gsap
|
|
18
19
|
```
|
|
19
20
|
|
|
21
|
+
> **Note**: As of v1.0.1, you no longer need to create a manual `directives.d.ts` file! Types are now automatically included.
|
|
22
|
+
|
|
20
23
|
## Quick Start
|
|
21
24
|
|
|
22
25
|
### Basic Usage
|
|
@@ -37,17 +40,26 @@ motion
|
|
|
37
40
|
### Solid.js Directive
|
|
38
41
|
|
|
39
42
|
```tsx
|
|
40
|
-
import { animate } from '@stellix-agency/motion';
|
|
43
|
+
import { animate, easings } from '@stellix-agency/motion';
|
|
41
44
|
|
|
42
45
|
function MyComponent() {
|
|
43
46
|
return (
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
<h1
|
|
48
|
+
use:animate={(m) =>
|
|
49
|
+
m.fadeIn({ ease: easings.smoothOut })
|
|
50
|
+
.wait(0.5)
|
|
51
|
+
.rotate(360, { ease: easings.elasticOut })
|
|
52
|
+
}
|
|
53
|
+
class="opacity-0 font-bold text-2xl mt-20 text-center"
|
|
54
|
+
>
|
|
55
|
+
Hello World
|
|
56
|
+
</h1>
|
|
47
57
|
);
|
|
48
58
|
}
|
|
49
59
|
```
|
|
50
60
|
|
|
61
|
+
> **Note**: You may see a "'animate' is declared but its value is never read" warning. This is expected and can be ignored - the import is required for the directive to work. See [USAGE.md](./USAGE.md) for details.
|
|
62
|
+
|
|
51
63
|
## Core API
|
|
52
64
|
|
|
53
65
|
### Motion Class
|
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,233 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
interface AnimationOptions extends Omit<gsap.TweenVars, 'duration' | 'ease'> {
|
|
5
|
-
/**
|
|
6
|
-
* Animation duration in seconds
|
|
7
|
-
* @default 0.8
|
|
8
|
-
*/
|
|
9
|
-
duration?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Easing function for the animation
|
|
12
|
-
* @default "power4.out"
|
|
13
|
-
*/
|
|
14
|
-
ease?: string | gsap.EaseFunction;
|
|
15
|
-
/**
|
|
16
|
-
* Delay before animation starts in seconds
|
|
17
|
-
* @default 0
|
|
18
|
-
*/
|
|
19
|
-
delay?: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Options for scroll-triggered animations
|
|
23
|
-
*/
|
|
24
|
-
interface ScrollAnimationOptions extends ScrollTrigger.Vars {
|
|
25
|
-
/**
|
|
26
|
-
* When the animation should start relative to the viewport
|
|
27
|
-
* @default "top 85%"
|
|
28
|
-
*/
|
|
29
|
-
start?: string;
|
|
30
|
-
/**
|
|
31
|
-
* When the animation should end relative to the viewport
|
|
32
|
-
*/
|
|
33
|
-
end?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Actions to perform: onEnter, onLeave, onEnterBack, onLeaveBack
|
|
36
|
-
* @default "play none none reverse"
|
|
37
|
-
*/
|
|
38
|
-
toggleActions?: string;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Direction for slide animations
|
|
42
|
-
*/
|
|
43
|
-
type SlideDirection = 'up' | 'down' | 'left' | 'right';
|
|
44
|
-
/**
|
|
45
|
-
* Fade animation variants
|
|
46
|
-
*/
|
|
47
|
-
type FadeVariant = 'in' | 'out' | 'inOut';
|
|
48
|
-
/**
|
|
49
|
-
* Preset animation configurations
|
|
50
|
-
*/
|
|
51
|
-
interface AnimationPreset {
|
|
52
|
-
duration: number;
|
|
53
|
-
ease: string;
|
|
54
|
-
[key: string]: any;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Core animation class providing a fluent API for GSAP animations
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```ts
|
|
62
|
-
* const motion = new Motion(element);
|
|
63
|
-
* motion.fadeIn().slideUp(50).scale(1.2).onScroll();
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
declare class Motion {
|
|
67
|
-
private timeline;
|
|
68
|
-
private element;
|
|
69
|
-
private defaultDuration;
|
|
70
|
-
private defaultEase;
|
|
71
|
-
private hasScrollTrigger;
|
|
72
|
-
/**
|
|
73
|
-
* Creates a new Motion instance
|
|
74
|
-
* @param element - The HTML element to animate
|
|
75
|
-
* @param autoStart - Whether to automatically start the animation (default: true)
|
|
76
|
-
*/
|
|
77
|
-
constructor(element: HTMLElement, autoStart?: boolean);
|
|
78
|
-
/**
|
|
79
|
-
* Internal method to add animations to the timeline
|
|
80
|
-
*/
|
|
81
|
-
private addAnimation;
|
|
82
|
-
/**
|
|
83
|
-
* Fade in animation
|
|
84
|
-
* @param options - Animation options
|
|
85
|
-
*/
|
|
86
|
-
fadeIn(options?: AnimationOptions): this;
|
|
87
|
-
/**
|
|
88
|
-
* Fade out animation
|
|
89
|
-
* @param options - Animation options
|
|
90
|
-
*/
|
|
91
|
-
fadeOut(options?: AnimationOptions): this;
|
|
92
|
-
/**
|
|
93
|
-
* Fade animation with variant
|
|
94
|
-
* @param variant - Fade variant ('in', 'out', or 'inOut')
|
|
95
|
-
* @param options - Animation options
|
|
96
|
-
*/
|
|
97
|
-
fade(variant?: FadeVariant, options?: AnimationOptions): this;
|
|
98
|
-
/**
|
|
99
|
-
* Slide animation in a specific direction
|
|
100
|
-
* @param direction - Direction to slide ('up', 'down', 'left', 'right')
|
|
101
|
-
* @param distance - Distance to slide in pixels (default: 50)
|
|
102
|
-
* @param options - Animation options
|
|
103
|
-
*/
|
|
104
|
-
slide(direction: SlideDirection, distance?: number, options?: AnimationOptions): this;
|
|
105
|
-
/**
|
|
106
|
-
* Slide up animation (commonly used for entrance)
|
|
107
|
-
* @param distance - Distance to slide in pixels
|
|
108
|
-
* @param options - Animation options
|
|
109
|
-
*/
|
|
110
|
-
slideUp(distance?: number, options?: AnimationOptions): this;
|
|
111
|
-
/**
|
|
112
|
-
* Slide down animation
|
|
113
|
-
* @param distance - Distance to slide in pixels
|
|
114
|
-
* @param options - Animation options
|
|
115
|
-
*/
|
|
116
|
-
slideDown(distance?: number, options?: AnimationOptions): this;
|
|
117
|
-
/**
|
|
118
|
-
* Slide left animation
|
|
119
|
-
* @param distance - Distance to slide in pixels
|
|
120
|
-
* @param options - Animation options
|
|
121
|
-
*/
|
|
122
|
-
slideLeft(distance?: number, options?: AnimationOptions): this;
|
|
123
|
-
/**
|
|
124
|
-
* Slide right animation
|
|
125
|
-
* @param distance - Distance to slide in pixels
|
|
126
|
-
* @param options - Animation options
|
|
127
|
-
*/
|
|
128
|
-
slideRight(distance?: number, options?: AnimationOptions): this;
|
|
129
|
-
/**
|
|
130
|
-
* Move to specific coordinates
|
|
131
|
-
* @param x - X coordinate in pixels
|
|
132
|
-
* @param y - Y coordinate in pixels
|
|
133
|
-
* @param options - Animation options
|
|
134
|
-
*/
|
|
135
|
-
moveTo(x: number, y: number, options?: AnimationOptions): this;
|
|
136
|
-
/**
|
|
137
|
-
* Scale animation
|
|
138
|
-
* @param scale - Scale factor (1 = original size)
|
|
139
|
-
* @param options - Animation options (default ease: "back.out(1.7)")
|
|
140
|
-
*/
|
|
141
|
-
scale(scale: number, options?: AnimationOptions): this;
|
|
142
|
-
/**
|
|
143
|
-
* Rotate animation
|
|
144
|
-
* @param degrees - Rotation in degrees
|
|
145
|
-
* @param options - Animation options
|
|
146
|
-
*/
|
|
147
|
-
rotate(degrees: number, options?: AnimationOptions): this;
|
|
148
|
-
/**
|
|
149
|
-
* Blur animation (requires CSS filters support)
|
|
150
|
-
* @param amount - Blur amount in pixels
|
|
151
|
-
* @param options - Animation options
|
|
152
|
-
*/
|
|
153
|
-
blur(amount: number, options?: AnimationOptions): this;
|
|
154
|
-
/**
|
|
155
|
-
* Skew animation
|
|
156
|
-
* @param x - Skew X in degrees
|
|
157
|
-
* @param y - Skew Y in degrees
|
|
158
|
-
* @param options - Animation options
|
|
159
|
-
*/
|
|
160
|
-
skew(x: number, y: number, options?: AnimationOptions): this;
|
|
161
|
-
/**
|
|
162
|
-
* Custom animation with any GSAP-supported properties
|
|
163
|
-
* @param vars - GSAP animation variables
|
|
164
|
-
* @param options - Animation options
|
|
165
|
-
*/
|
|
166
|
-
animate(vars: gsap.TweenVars, options?: AnimationOptions): this;
|
|
167
|
-
/**
|
|
168
|
-
* Add a delay/pause in the animation sequence
|
|
169
|
-
* @param duration - Wait duration in seconds
|
|
170
|
-
*/
|
|
171
|
-
wait(duration: number): this;
|
|
172
|
-
/**
|
|
173
|
-
* Set the default duration for subsequent animations
|
|
174
|
-
* @param duration - Duration in seconds
|
|
175
|
-
*/
|
|
176
|
-
setDuration(duration: number): this;
|
|
177
|
-
/**
|
|
178
|
-
* Set the default easing for subsequent animations
|
|
179
|
-
* @param ease - Easing function or string
|
|
180
|
-
*/
|
|
181
|
-
setEase(ease: string | gsap.EaseFunction): this;
|
|
182
|
-
/**
|
|
183
|
-
* Add ScrollTrigger to the animation
|
|
184
|
-
* @param options - ScrollTrigger options
|
|
185
|
-
*/
|
|
186
|
-
onScroll(options?: ScrollAnimationOptions): this;
|
|
187
|
-
/**
|
|
188
|
-
* Play the animation timeline
|
|
189
|
-
*/
|
|
190
|
-
play(): this;
|
|
191
|
-
/**
|
|
192
|
-
* Pause the animation timeline
|
|
193
|
-
*/
|
|
194
|
-
pause(): this;
|
|
195
|
-
/**
|
|
196
|
-
* Restart the animation timeline
|
|
197
|
-
*/
|
|
198
|
-
restart(): this;
|
|
199
|
-
/**
|
|
200
|
-
* Reverse the animation timeline
|
|
201
|
-
*/
|
|
202
|
-
reverse(): this;
|
|
203
|
-
/**
|
|
204
|
-
* Get the underlying GSAP timeline
|
|
205
|
-
*/
|
|
206
|
-
getTimeline(): gsap.core.Timeline;
|
|
207
|
-
/**
|
|
208
|
-
* Kill the animation and clean up
|
|
209
|
-
*/
|
|
210
|
-
kill(): void;
|
|
211
|
-
}
|
|
1
|
+
import { M as Motion, A as AnimationOptions } from './jsx.js';
|
|
2
|
+
export { a as AnimationPreset, F as FadeVariant, S as ScrollAnimationOptions, b as SlideDirection } from './jsx.js';
|
|
212
3
|
|
|
213
4
|
/**
|
|
214
5
|
* Solid.js directive for declarative animations
|
|
215
6
|
*
|
|
216
7
|
* @example
|
|
217
8
|
* ```tsx
|
|
9
|
+
* import { animate } from '@stellix-agency/motion';
|
|
10
|
+
*
|
|
11
|
+
* // The directive is used via use:animate, not called directly
|
|
218
12
|
* <div use:animate={(m) => m.fadeIn().slideUp().onScroll()}>
|
|
219
13
|
* Content
|
|
220
14
|
* </div>
|
|
221
15
|
* ```
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* This function is used as a Solid.js directive and should be imported
|
|
19
|
+
* even if your IDE shows it as unused. The import is required for the
|
|
20
|
+
* directive to work properly.
|
|
222
21
|
*/
|
|
223
22
|
declare function animate(element: HTMLElement, accessor: () => (motion: Motion) => void): void;
|
|
224
|
-
declare module 'solid-js' {
|
|
225
|
-
namespace JSX {
|
|
226
|
-
interface Directives {
|
|
227
|
-
animate: (motion: Motion) => void;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
23
|
|
|
232
24
|
/**
|
|
233
25
|
* Create a stagger animation for multiple elements
|
|
@@ -330,4 +122,4 @@ declare const easings: {
|
|
|
330
122
|
expoIn: string;
|
|
331
123
|
};
|
|
332
124
|
|
|
333
|
-
export {
|
|
125
|
+
export { AnimationOptions, Motion, Motion as MotionCore, animate, batch, easings, hover, parallax, presets, reveal, scrollEntrance, stagger };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{gsap as b}from"gsap";import{ScrollTrigger as M}from"gsap/ScrollTrigger";import{gsap as l}from"gsap";import{ScrollTrigger as p}from"gsap/ScrollTrigger";var r=class{timeline;element;defaultDuration=.8;defaultEase="power4.out";hasScrollTrigger=!1;constructor(t,i=!0){this.element=t,l.set(this.element,{opacity:0,y:20}),this.timeline=l.timeline({paused:!0}),i&&Promise.resolve().then(()=>{this.hasScrollTrigger||this.play()})}addAnimation(t,i){let{duration:n,ease:o,delay:a,...s}=i||{};return this.timeline.to(this.element,{...t,duration:n??this.defaultDuration,ease:o??this.defaultEase,delay:a??0,...s},">"),this}fadeIn(t){return this.addAnimation({opacity:1},t)}fadeOut(t){return this.addAnimation({opacity:0},t)}fade(t="in",i){switch(t){case"in":return this.fadeIn(i);case"out":return this.fadeOut(i);case"inOut":return this.fadeIn(i).fadeOut(i);default:return this.fadeIn(i)}}slide(t,i=50,n){let o={up:{y:0,x:0},down:{y:i,x:0},left:{x:0,y:0},right:{x:i,y:0}};return this.addAnimation(o[t],n)}slideUp(t=50,i){return this.addAnimation({y:0},i)}slideDown(t=50,i){return this.addAnimation({y:t},i)}slideLeft(t=50,i){return this.addAnimation({x:-t},i)}slideRight(t=50,i){return this.addAnimation({x:t},i)}moveTo(t,i,n){return this.addAnimation({x:t,y:i},n)}scale(t,i){return this.addAnimation({scale:t},{ease:"back.out(1.7)",...i})}rotate(t,i){return this.addAnimation({rotation:t},i)}blur(t,i){return this.addAnimation({filter:`blur(${t}px)`},i)}skew(t,i,n){return this.addAnimation({skewX:t,skewY:i},n)}animate(t,i){return this.addAnimation(t,i)}wait(t){return this.timeline.to({},{duration:t},">"),this}setDuration(t){return this.defaultDuration=t,this}setEase(t){return this.defaultEase=t,this}onScroll(t){return this.hasScrollTrigger=!0,p.create({trigger:this.element,start:"top 85%",animation:this.timeline,toggleActions:"play none none reverse",...t}),this}play(){return this.timeline.play(),this}pause(){return this.timeline.pause(),this}restart(){return this.timeline.restart(),this}reverse(){return this.timeline.reverse(),this}getTimeline(){return this.timeline}kill(){this.timeline.kill(),this.hasScrollTrigger&&p.getById(this.timeline.scrollTrigger?.vars.id)?.kill()}};import{onCleanup as c}from"solid-js";function d(e,t){try{let i=t();if(typeof i!="function"){console.warn("[Magic Motion] animate directive expects a function");return}let n=new r(e);setTimeout(()=>{try{i(n)}catch(o){console.error("[Magic Motion] Error setting up animation:",o)}},0),c(()=>{n.kill()})}catch(i){console.error("[Magic Motion] Error initializing animation:",i)}}import{gsap as m}from"gsap";function h(e,t,i=.1){return Array.from(typeof e=="string"?document.querySelectorAll(e):e).map((o,a)=>{let s=new r(o,!1);return a>0&&s.wait(i*a),t(s,a),s.play(),s})}function f(e,t){return Array.from(typeof e=="string"?document.querySelectorAll(e):e).map(n=>{let o=new r(n);return t(o),o})}function g(e,t){return new r(e,!1).fadeIn(t).slideUp(30,t).onScroll()}function A(e,t,i){let{duration:n=.3,ease:o="power2.out",...a}=i||{},s=()=>{m.to(e,{...t,duration:n,ease:o,...a})},u=()=>{m.to(e,{scale:1,x:0,y:0,rotation:0,duration:n,ease:o,...a})};return e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",u),()=>{e.removeEventListener("mouseenter",s),e.removeEventListener("mouseleave",u)}}function O(e,t=.5){return m.to(e,{y:()=>window.innerHeight*t,ease:"none",scrollTrigger:{trigger:e,start:"top bottom",end:"bottom top",scrub:!0}})}function y(e,t="bottom",i){let n=new r(e,!1);return{left:()=>n.slideRight(100,i),right:()=>n.slideLeft(100,i),top:()=>n.slideDown(100,i),bottom:()=>n.slideUp(100,i)}[t]().fadeIn(i)}var
|
|
1
|
+
import"./chunk-YEOCNWCQ.js";import{gsap as b}from"gsap";import{ScrollTrigger as M}from"gsap/ScrollTrigger";import{gsap as l}from"gsap";import{ScrollTrigger as p}from"gsap/ScrollTrigger";var r=class{timeline;element;defaultDuration=.8;defaultEase="power4.out";hasScrollTrigger=!1;constructor(t,i=!0){this.element=t,l.set(this.element,{opacity:0,y:20}),this.timeline=l.timeline({paused:!0}),i&&Promise.resolve().then(()=>{this.hasScrollTrigger||this.play()})}addAnimation(t,i){let{duration:n,ease:o,delay:a,...s}=i||{};return this.timeline.to(this.element,{...t,duration:n??this.defaultDuration,ease:o??this.defaultEase,delay:a??0,...s},">"),this}fadeIn(t){return this.addAnimation({opacity:1},t)}fadeOut(t){return this.addAnimation({opacity:0},t)}fade(t="in",i){switch(t){case"in":return this.fadeIn(i);case"out":return this.fadeOut(i);case"inOut":return this.fadeIn(i).fadeOut(i);default:return this.fadeIn(i)}}slide(t,i=50,n){let o={up:{y:0,x:0},down:{y:i,x:0},left:{x:0,y:0},right:{x:i,y:0}};return this.addAnimation(o[t],n)}slideUp(t=50,i){return this.addAnimation({y:0},i)}slideDown(t=50,i){return this.addAnimation({y:t},i)}slideLeft(t=50,i){return this.addAnimation({x:-t},i)}slideRight(t=50,i){return this.addAnimation({x:t},i)}moveTo(t,i,n){return this.addAnimation({x:t,y:i},n)}scale(t,i){return this.addAnimation({scale:t},{ease:"back.out(1.7)",...i})}rotate(t,i){return this.addAnimation({rotation:t},i)}blur(t,i){return this.addAnimation({filter:`blur(${t}px)`},i)}skew(t,i,n){return this.addAnimation({skewX:t,skewY:i},n)}animate(t,i){return this.addAnimation(t,i)}wait(t){return this.timeline.to({},{duration:t},">"),this}setDuration(t){return this.defaultDuration=t,this}setEase(t){return this.defaultEase=t,this}onScroll(t){return this.hasScrollTrigger=!0,p.create({trigger:this.element,start:"top 85%",animation:this.timeline,toggleActions:"play none none reverse",...t}),this}play(){return this.timeline.play(),this}pause(){return this.timeline.pause(),this}restart(){return this.timeline.restart(),this}reverse(){return this.timeline.reverse(),this}getTimeline(){return this.timeline}kill(){this.timeline.kill(),this.hasScrollTrigger&&p.getById(this.timeline.scrollTrigger?.vars.id)?.kill()}};import{onCleanup as c}from"solid-js";function d(e,t){try{let i=t();if(typeof i!="function"){console.warn("[Magic Motion] animate directive expects a function");return}let n=new r(e);setTimeout(()=>{try{i(n)}catch(o){console.error("[Magic Motion] Error setting up animation:",o)}},0),c(()=>{n.kill()})}catch(i){console.error("[Magic Motion] Error initializing animation:",i)}}import{gsap as m}from"gsap";function h(e,t,i=.1){return Array.from(typeof e=="string"?document.querySelectorAll(e):e).map((o,a)=>{let s=new r(o,!1);return a>0&&s.wait(i*a),t(s,a),s.play(),s})}function f(e,t){return Array.from(typeof e=="string"?document.querySelectorAll(e):e).map(n=>{let o=new r(n);return t(o),o})}function g(e,t){return new r(e,!1).fadeIn(t).slideUp(30,t).onScroll()}function A(e,t,i){let{duration:n=.3,ease:o="power2.out",...a}=i||{},s=()=>{m.to(e,{...t,duration:n,ease:o,...a})},u=()=>{m.to(e,{scale:1,x:0,y:0,rotation:0,duration:n,ease:o,...a})};return e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",u),()=>{e.removeEventListener("mouseenter",s),e.removeEventListener("mouseleave",u)}}function O(e,t=.5){return m.to(e,{y:()=>window.innerHeight*t,ease:"none",scrollTrigger:{trigger:e,start:"top bottom",end:"bottom top",scrub:!0}})}function y(e,t="bottom",i){let n=new r(e,!1);return{left:()=>n.slideRight(100,i),right:()=>n.slideLeft(100,i),top:()=>n.slideDown(100,i),bottom:()=>n.slideUp(100,i)}[t]().fadeIn(i)}var w={fast:{duration:.3,ease:"power2.out"},normal:{duration:.8,ease:"power4.out"},slow:{duration:1.5,ease:"power4.out"},bounce:{duration:.8,ease:"elastic.out(1, 0.5)"},spring:{duration:.6,ease:"back.out(1.7)"},smooth:{duration:1,ease:"power2.inOut"},sharp:{duration:.4,ease:"power4.in"},elastic:{duration:1,ease:"elastic.out(1, 0.3)"}},v={linear:"none",easeIn:"power2.in",easeOut:"power2.out",easeInOut:"power2.inOut",smoothIn:"power4.in",smoothOut:"power4.out",smoothInOut:"power4.inOut",bounceOut:"bounce.out",bounceIn:"bounce.in",bounceInOut:"bounce.inOut",elasticOut:"elastic.out(1, 0.3)",elasticIn:"elastic.in(1, 0.3)",backOut:"back.out(1.7)",backIn:"back.in(1.7)",circOut:"circ.out",circIn:"circ.in",expoOut:"expo.out",expoIn:"expo.in"};typeof window<"u"&&b.registerPlugin(M);export{r as Motion,r as MotionCore,d as animate,f as batch,v as easings,A as hover,O as parallax,w as presets,y as reveal,g as scrollEntrance,h as stagger};
|
package/dist/jsx.d.ts
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base animation options that extend GSAP's TweenVars
|
|
3
|
+
*/
|
|
4
|
+
interface AnimationOptions extends Omit<gsap.TweenVars, 'duration' | 'ease'> {
|
|
5
|
+
/**
|
|
6
|
+
* Animation duration in seconds
|
|
7
|
+
* @default 0.8
|
|
8
|
+
*/
|
|
9
|
+
duration?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Easing function for the animation
|
|
12
|
+
* @default "power4.out"
|
|
13
|
+
*/
|
|
14
|
+
ease?: string | gsap.EaseFunction;
|
|
15
|
+
/**
|
|
16
|
+
* Delay before animation starts in seconds
|
|
17
|
+
* @default 0
|
|
18
|
+
*/
|
|
19
|
+
delay?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Options for scroll-triggered animations
|
|
23
|
+
*/
|
|
24
|
+
interface ScrollAnimationOptions extends ScrollTrigger.Vars {
|
|
25
|
+
/**
|
|
26
|
+
* When the animation should start relative to the viewport
|
|
27
|
+
* @default "top 85%"
|
|
28
|
+
*/
|
|
29
|
+
start?: string;
|
|
30
|
+
/**
|
|
31
|
+
* When the animation should end relative to the viewport
|
|
32
|
+
*/
|
|
33
|
+
end?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Actions to perform: onEnter, onLeave, onEnterBack, onLeaveBack
|
|
36
|
+
* @default "play none none reverse"
|
|
37
|
+
*/
|
|
38
|
+
toggleActions?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Direction for slide animations
|
|
42
|
+
*/
|
|
43
|
+
type SlideDirection = 'up' | 'down' | 'left' | 'right';
|
|
44
|
+
/**
|
|
45
|
+
* Fade animation variants
|
|
46
|
+
*/
|
|
47
|
+
type FadeVariant = 'in' | 'out' | 'inOut';
|
|
48
|
+
/**
|
|
49
|
+
* Preset animation configurations
|
|
50
|
+
*/
|
|
51
|
+
interface AnimationPreset {
|
|
52
|
+
duration: number;
|
|
53
|
+
ease: string;
|
|
54
|
+
[key: string]: any;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Core animation class providing a fluent API for GSAP animations
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const motion = new Motion(element);
|
|
63
|
+
* motion.fadeIn().slideUp(50).scale(1.2).onScroll();
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
declare class Motion {
|
|
67
|
+
private timeline;
|
|
68
|
+
private element;
|
|
69
|
+
private defaultDuration;
|
|
70
|
+
private defaultEase;
|
|
71
|
+
private hasScrollTrigger;
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new Motion instance
|
|
74
|
+
* @param element - The HTML element to animate
|
|
75
|
+
* @param autoStart - Whether to automatically start the animation (default: true)
|
|
76
|
+
*/
|
|
77
|
+
constructor(element: HTMLElement, autoStart?: boolean);
|
|
78
|
+
/**
|
|
79
|
+
* Internal method to add animations to the timeline
|
|
80
|
+
*/
|
|
81
|
+
private addAnimation;
|
|
82
|
+
/**
|
|
83
|
+
* Fade in animation
|
|
84
|
+
* @param options - Animation options
|
|
85
|
+
*/
|
|
86
|
+
fadeIn(options?: AnimationOptions): this;
|
|
87
|
+
/**
|
|
88
|
+
* Fade out animation
|
|
89
|
+
* @param options - Animation options
|
|
90
|
+
*/
|
|
91
|
+
fadeOut(options?: AnimationOptions): this;
|
|
92
|
+
/**
|
|
93
|
+
* Fade animation with variant
|
|
94
|
+
* @param variant - Fade variant ('in', 'out', or 'inOut')
|
|
95
|
+
* @param options - Animation options
|
|
96
|
+
*/
|
|
97
|
+
fade(variant?: FadeVariant, options?: AnimationOptions): this;
|
|
98
|
+
/**
|
|
99
|
+
* Slide animation in a specific direction
|
|
100
|
+
* @param direction - Direction to slide ('up', 'down', 'left', 'right')
|
|
101
|
+
* @param distance - Distance to slide in pixels (default: 50)
|
|
102
|
+
* @param options - Animation options
|
|
103
|
+
*/
|
|
104
|
+
slide(direction: SlideDirection, distance?: number, options?: AnimationOptions): this;
|
|
105
|
+
/**
|
|
106
|
+
* Slide up animation (commonly used for entrance)
|
|
107
|
+
* @param distance - Distance to slide in pixels
|
|
108
|
+
* @param options - Animation options
|
|
109
|
+
*/
|
|
110
|
+
slideUp(distance?: number, options?: AnimationOptions): this;
|
|
111
|
+
/**
|
|
112
|
+
* Slide down animation
|
|
113
|
+
* @param distance - Distance to slide in pixels
|
|
114
|
+
* @param options - Animation options
|
|
115
|
+
*/
|
|
116
|
+
slideDown(distance?: number, options?: AnimationOptions): this;
|
|
117
|
+
/**
|
|
118
|
+
* Slide left animation
|
|
119
|
+
* @param distance - Distance to slide in pixels
|
|
120
|
+
* @param options - Animation options
|
|
121
|
+
*/
|
|
122
|
+
slideLeft(distance?: number, options?: AnimationOptions): this;
|
|
123
|
+
/**
|
|
124
|
+
* Slide right animation
|
|
125
|
+
* @param distance - Distance to slide in pixels
|
|
126
|
+
* @param options - Animation options
|
|
127
|
+
*/
|
|
128
|
+
slideRight(distance?: number, options?: AnimationOptions): this;
|
|
129
|
+
/**
|
|
130
|
+
* Move to specific coordinates
|
|
131
|
+
* @param x - X coordinate in pixels
|
|
132
|
+
* @param y - Y coordinate in pixels
|
|
133
|
+
* @param options - Animation options
|
|
134
|
+
*/
|
|
135
|
+
moveTo(x: number, y: number, options?: AnimationOptions): this;
|
|
136
|
+
/**
|
|
137
|
+
* Scale animation
|
|
138
|
+
* @param scale - Scale factor (1 = original size)
|
|
139
|
+
* @param options - Animation options (default ease: "back.out(1.7)")
|
|
140
|
+
*/
|
|
141
|
+
scale(scale: number, options?: AnimationOptions): this;
|
|
142
|
+
/**
|
|
143
|
+
* Rotate animation
|
|
144
|
+
* @param degrees - Rotation in degrees
|
|
145
|
+
* @param options - Animation options
|
|
146
|
+
*/
|
|
147
|
+
rotate(degrees: number, options?: AnimationOptions): this;
|
|
148
|
+
/**
|
|
149
|
+
* Blur animation (requires CSS filters support)
|
|
150
|
+
* @param amount - Blur amount in pixels
|
|
151
|
+
* @param options - Animation options
|
|
152
|
+
*/
|
|
153
|
+
blur(amount: number, options?: AnimationOptions): this;
|
|
154
|
+
/**
|
|
155
|
+
* Skew animation
|
|
156
|
+
* @param x - Skew X in degrees
|
|
157
|
+
* @param y - Skew Y in degrees
|
|
158
|
+
* @param options - Animation options
|
|
159
|
+
*/
|
|
160
|
+
skew(x: number, y: number, options?: AnimationOptions): this;
|
|
161
|
+
/**
|
|
162
|
+
* Custom animation with any GSAP-supported properties
|
|
163
|
+
* @param vars - GSAP animation variables
|
|
164
|
+
* @param options - Animation options
|
|
165
|
+
*/
|
|
166
|
+
animate(vars: gsap.TweenVars, options?: AnimationOptions): this;
|
|
167
|
+
/**
|
|
168
|
+
* Add a delay/pause in the animation sequence
|
|
169
|
+
* @param duration - Wait duration in seconds
|
|
170
|
+
*/
|
|
171
|
+
wait(duration: number): this;
|
|
172
|
+
/**
|
|
173
|
+
* Set the default duration for subsequent animations
|
|
174
|
+
* @param duration - Duration in seconds
|
|
175
|
+
*/
|
|
176
|
+
setDuration(duration: number): this;
|
|
177
|
+
/**
|
|
178
|
+
* Set the default easing for subsequent animations
|
|
179
|
+
* @param ease - Easing function or string
|
|
180
|
+
*/
|
|
181
|
+
setEase(ease: string | gsap.EaseFunction): this;
|
|
182
|
+
/**
|
|
183
|
+
* Add ScrollTrigger to the animation
|
|
184
|
+
* @param options - ScrollTrigger options
|
|
185
|
+
*/
|
|
186
|
+
onScroll(options?: ScrollAnimationOptions): this;
|
|
187
|
+
/**
|
|
188
|
+
* Play the animation timeline
|
|
189
|
+
*/
|
|
190
|
+
play(): this;
|
|
191
|
+
/**
|
|
192
|
+
* Pause the animation timeline
|
|
193
|
+
*/
|
|
194
|
+
pause(): this;
|
|
195
|
+
/**
|
|
196
|
+
* Restart the animation timeline
|
|
197
|
+
*/
|
|
198
|
+
restart(): this;
|
|
199
|
+
/**
|
|
200
|
+
* Reverse the animation timeline
|
|
201
|
+
*/
|
|
202
|
+
reverse(): this;
|
|
203
|
+
/**
|
|
204
|
+
* Get the underlying GSAP timeline
|
|
205
|
+
*/
|
|
206
|
+
getTimeline(): gsap.core.Timeline;
|
|
207
|
+
/**
|
|
208
|
+
* Kill the animation and clean up
|
|
209
|
+
*/
|
|
210
|
+
kill(): void;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
declare module 'solid-js' {
|
|
214
|
+
namespace JSX {
|
|
215
|
+
interface Directives {
|
|
216
|
+
animate: (motion: Motion) => void;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export { type AnimationOptions as A, type FadeVariant as F, Motion as M, type ScrollAnimationOptions as S, type AnimationPreset as a, type SlideDirection as b };
|
package/dist/jsx.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-YEOCNWCQ.js";
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.2",
|
|
7
7
|
"description": "An intuitive GSAP wrapper for creating stunning animations with ease.",
|
|
8
8
|
"author": "Stellix Agency",
|
|
9
9
|
"license": "MIT",
|
|
@@ -17,12 +17,32 @@
|
|
|
17
17
|
"main": "./dist/index.js",
|
|
18
18
|
"module": "./dist/index.js",
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./jsx": {
|
|
27
|
+
"types": "./dist/jsx.d.ts"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
20
30
|
"files": [
|
|
21
31
|
"dist"
|
|
22
32
|
],
|
|
33
|
+
"typesVersions": {
|
|
34
|
+
"*": {
|
|
35
|
+
"*": [
|
|
36
|
+
"./dist/index.d.ts"
|
|
37
|
+
],
|
|
38
|
+
"jsx": [
|
|
39
|
+
"./dist/jsx.d.ts"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
23
43
|
"scripts": {
|
|
24
|
-
"build": "tsup
|
|
25
|
-
"dev": "tsup
|
|
44
|
+
"build": "tsup",
|
|
45
|
+
"dev": "tsup --watch"
|
|
26
46
|
},
|
|
27
47
|
"peerDependencies": {
|
|
28
48
|
"gsap": "^3.14.2",
|