@stellix-agency/motion 1.0.0 → 1.0.1

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 ADDED
@@ -0,0 +1,345 @@
1
+ # Magic Motion 🎬
2
+
3
+ An intuitive and powerful GSAP wrapper for creating stunning animations with ease. Built for Solid.js and Astro projects.
4
+
5
+ ## Features
6
+
7
+ ✨ **Fluent API** - Chain animations naturally with an intuitive syntax
8
+ 🎯 **TypeScript First** - Full type safety with comprehensive JSDoc
9
+ 📜 **Scroll Animations** - Easy ScrollTrigger integration
10
+ 🎨 **Rich Presets** - Common animation patterns out of the box
11
+ 🔧 **Utility Functions** - Stagger, batch, parallax, and more
12
+ ⚡ **Lightweight** - Minimal wrapper over GSAP's powerful engine
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @stellix-agency/motion gsap
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ### Basic Usage
23
+
24
+ ```typescript
25
+ import { Motion } from '@stellix-agency/motion';
26
+
27
+ const element = document.querySelector('.box');
28
+ const motion = new Motion(element);
29
+
30
+ motion
31
+ .fadeIn()
32
+ .slideUp(50)
33
+ .scale(1.2)
34
+ .rotate(360);
35
+ ```
36
+
37
+ ### Solid.js Directive
38
+
39
+ ```tsx
40
+ import { animate } from '@stellix-agency/motion';
41
+
42
+ function MyComponent() {
43
+ return (
44
+ <div use:animate={(m) => m.fadeIn().slideUp().onScroll()}>
45
+ Animated content
46
+ </div>
47
+ );
48
+ }
49
+ ```
50
+
51
+ ## Core API
52
+
53
+ ### Motion Class
54
+
55
+ The `Motion` class provides a fluent API for chaining animations:
56
+
57
+ #### Fade Animations
58
+
59
+ ```typescript
60
+ motion.fadeIn(options?) // Fade in
61
+ motion.fadeOut(options?) // Fade out
62
+ motion.fade('in' | 'out' | 'inOut', options?) // Fade variant
63
+ ```
64
+
65
+ #### Slide Animations
66
+
67
+ ```typescript
68
+ motion.slideUp(distance?, options?) // Slide up
69
+ motion.slideDown(distance?, options?) // Slide down
70
+ motion.slideLeft(distance?, options?) // Slide left
71
+ motion.slideRight(distance?, options?) // Slide right
72
+ motion.slide(direction, distance?, options?) // Slide in any direction
73
+ ```
74
+
75
+ #### Transform Animations
76
+
77
+ ```typescript
78
+ motion.scale(scale, options?) // Scale element
79
+ motion.rotate(degrees, options?) // Rotate element
80
+ motion.skew(x, y, options?) // Skew element
81
+ motion.moveTo(x, y, options?) // Move to coordinates
82
+ ```
83
+
84
+ #### Effects
85
+
86
+ ```typescript
87
+ motion.blur(amount, options?) // Blur effect
88
+ ```
89
+
90
+ #### Custom Animations
91
+
92
+ ```typescript
93
+ motion.animate(vars, options?) // Custom GSAP properties
94
+ ```
95
+
96
+ #### Timeline Control
97
+
98
+ ```typescript
99
+ motion.wait(duration) // Add delay
100
+ motion.setDuration(duration) // Set default duration
101
+ motion.setEase(ease) // Set default easing
102
+ ```
103
+
104
+ #### Playback Control
105
+
106
+ ```typescript
107
+ motion.play() // Play animation
108
+ motion.pause() // Pause animation
109
+ motion.restart() // Restart animation
110
+ motion.reverse() // Reverse animation
111
+ motion.kill() // Kill and cleanup
112
+ ```
113
+
114
+ #### Scroll Trigger
115
+
116
+ ```typescript
117
+ motion.onScroll(options?) // Add ScrollTrigger
118
+ ```
119
+
120
+ ### Animation Options
121
+
122
+ ```typescript
123
+ interface AnimationOptions {
124
+ duration?: number; // Animation duration (default: 0.8s)
125
+ ease?: string; // Easing function (default: "power4.out")
126
+ delay?: number; // Delay before start
127
+ // ...all GSAP TweenVars
128
+ }
129
+ ```
130
+
131
+ ### Scroll Options
132
+
133
+ ```typescript
134
+ interface ScrollAnimationOptions {
135
+ start?: string; // Start position (default: "top 85%")
136
+ end?: string; // End position
137
+ toggleActions?: string; // Actions (default: "play none none reverse")
138
+ // ...all ScrollTrigger.Vars
139
+ }
140
+ ```
141
+
142
+ ## Presets
143
+
144
+ Pre-configured animation settings for common use cases:
145
+
146
+ ```typescript
147
+ import { presets } from '@stellix-agency/motion';
148
+
149
+ motion.fadeIn(presets.fast) // Quick animation (0.3s)
150
+ motion.fadeIn(presets.normal) // Standard animation (0.8s)
151
+ motion.fadeIn(presets.slow) // Slow animation (1.5s)
152
+ motion.scale(1.2, presets.bounce) // Bouncy animation
153
+ motion.fadeIn(presets.spring) // Spring-like animation
154
+ motion.fadeIn(presets.smooth) // Smooth ease in/out
155
+ motion.fadeIn(presets.elastic) // Elastic bounce
156
+ ```
157
+
158
+ ## Easings
159
+
160
+ Common easing functions:
161
+
162
+ ```typescript
163
+ import { easings } from '@stellix-agency/motion';
164
+
165
+ motion.fadeIn({ ease: easings.smoothOut })
166
+ motion.scale(1.2, { ease: easings.backOut })
167
+ motion.rotate(360, { ease: easings.elasticOut })
168
+ ```
169
+
170
+ Available easings: `linear`, `easeIn`, `easeOut`, `easeInOut`, `smoothIn`, `smoothOut`, `smoothInOut`, `bounceOut`, `bounceIn`, `bounceInOut`, `elasticOut`, `elasticIn`, `backOut`, `backIn`, `circOut`, `circIn`, `expoOut`, `expoIn`
171
+
172
+ ## Utility Functions
173
+
174
+ ### Stagger
175
+
176
+ Animate multiple elements with a stagger delay:
177
+
178
+ ```typescript
179
+ import { stagger } from '@stellix-agency/motion';
180
+
181
+ stagger('.card', (motion, index) => {
182
+ motion.fadeIn().slideUp().onScroll();
183
+ }, 0.1); // 0.1s delay between each
184
+ ```
185
+
186
+ ### Batch
187
+
188
+ Apply the same animation to multiple elements:
189
+
190
+ ```typescript
191
+ import { batch } from '@stellix-agency/motion';
192
+
193
+ batch('.item', (motion) => {
194
+ motion.fadeIn({ duration: 0.5 });
195
+ });
196
+ ```
197
+
198
+ ### Scroll Entrance
199
+
200
+ Quick scroll-triggered entrance animation:
201
+
202
+ ```typescript
203
+ import { scrollEntrance } from '@stellix-agency/motion';
204
+
205
+ const element = document.querySelector('.hero');
206
+ scrollEntrance(element, { duration: 1 });
207
+ ```
208
+
209
+ ### Hover
210
+
211
+ Create hover animations:
212
+
213
+ ```typescript
214
+ import { hover } from '@stellix-agency/motion';
215
+
216
+ const cleanup = hover(
217
+ element,
218
+ { scale: 1.1, y: -10 },
219
+ { duration: 0.3 }
220
+ );
221
+
222
+ // Call cleanup() when done
223
+ ```
224
+
225
+ ### Parallax
226
+
227
+ Create parallax scroll effects:
228
+
229
+ ```typescript
230
+ import { parallax } from '@stellix-agency/motion';
231
+
232
+ parallax(element, 0.5); // 0.5 = speed multiplier
233
+ ```
234
+
235
+ ### Reveal
236
+
237
+ Reveal animation from a direction:
238
+
239
+ ```typescript
240
+ import { reveal } from '@stellix-agency/motion';
241
+
242
+ reveal(element, 'bottom', { duration: 1 });
243
+ // directions: 'left' | 'right' | 'top' | 'bottom'
244
+ ```
245
+
246
+ ## Examples
247
+
248
+ ### Hero Section with Scroll Trigger
249
+
250
+ ```typescript
251
+ const hero = new Motion(heroElement);
252
+ hero
253
+ .fadeIn({ duration: 1.2 })
254
+ .slideUp(100, { duration: 1 })
255
+ .scale(1, { ease: 'back.out(1.7)' })
256
+ .onScroll({ start: 'top center' });
257
+ ```
258
+
259
+ ### Staggered Cards
260
+
261
+ ```typescript
262
+ stagger('.card', (motion, index) => {
263
+ motion
264
+ .fadeIn()
265
+ .slideUp(30)
266
+ .scale(1)
267
+ .onScroll();
268
+ }, 0.15);
269
+ ```
270
+
271
+ ### Complex Sequence
272
+
273
+ ```typescript
274
+ const element = new Motion(box);
275
+ element
276
+ .fadeIn({ duration: 0.5 })
277
+ .wait(0.2)
278
+ .slideUp(50, { duration: 0.8 })
279
+ .scale(1.2, { duration: 0.5, ease: 'back.out(1.7)' })
280
+ .rotate(360, { duration: 1 })
281
+ .wait(0.5)
282
+ .slideDown(20, { duration: 0.3 });
283
+ ```
284
+
285
+ ### Solid.js Component
286
+
287
+ ```tsx
288
+ import { animate } from '@stellix-agency/motion';
289
+
290
+ function AnimatedCard() {
291
+ return (
292
+ <div
293
+ class="card"
294
+ use:animate={(m) =>
295
+ m.fadeIn()
296
+ .slideUp(50)
297
+ .scale(1)
298
+ .onScroll({ start: 'top 90%' })
299
+ }
300
+ >
301
+ <h2>Card Title</h2>
302
+ <p>Card content</p>
303
+ </div>
304
+ );
305
+ }
306
+ ```
307
+
308
+ ### Custom Animation with GSAP Properties
309
+
310
+ ```typescript
311
+ motion.animate({
312
+ background: 'linear-gradient(45deg, #667eea 0%, #764ba2 100%)',
313
+ borderRadius: '50%',
314
+ boxShadow: '0 10px 30px rgba(0,0,0,0.3)'
315
+ }, { duration: 1.5, ease: 'power2.inOut' });
316
+ ```
317
+
318
+ ## TypeScript Support
319
+
320
+ Full TypeScript support with exported types:
321
+
322
+ ```typescript
323
+ import type {
324
+ AnimationOptions,
325
+ ScrollAnimationOptions,
326
+ SlideDirection,
327
+ FadeVariant,
328
+ AnimationPreset
329
+ } from '@stellix-agency/motion';
330
+ ```
331
+
332
+ ## Browser Support
333
+
334
+ - Modern browsers with ES6+ support
335
+ - Requires GSAP 3.14.2+
336
+ - ScrollTrigger plugin included
337
+
338
+ ## License
339
+
340
+ MIT © Stellix Agency
341
+
342
+ ## Credits
343
+
344
+ Built with ❤️ by [Stellix Agency](https://stellix.agency)
345
+ Powered by [GSAP](https://gsap.com)
package/dist/index.d.ts CHANGED
@@ -1,23 +1,333 @@
1
- interface MotionOptions extends gsap.TweenVars {
2
- d?: number;
3
- e?: string;
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;
4
211
  }
5
- declare class MotionCore {
6
- private tl;
7
- private el;
8
- private defaults;
9
- constructor(el: HTMLElement);
10
- private add;
11
- in(options?: MotionOptions): this;
12
- move(x: number, y: number, options?: MotionOptions): this;
13
- scale(s: number, options?: MotionOptions): this;
14
- wait(d: number): this;
15
- /**
16
- * Utilisation du type Vars de ScrollTrigger (le plus moderne)
17
- */
18
- onScroll(st?: ScrollTrigger.Vars): this;
212
+
213
+ /**
214
+ * Solid.js directive for declarative animations
215
+ *
216
+ * @example
217
+ * ```tsx
218
+ * <div use:animate={(m) => m.fadeIn().slideUp().onScroll()}>
219
+ * Content
220
+ * </div>
221
+ * ```
222
+ */
223
+ 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
+ }
19
230
  }
20
231
 
21
- declare function animate(el: HTMLElement, accessor: () => (m: MotionCore) => void): void;
232
+ /**
233
+ * Create a stagger animation for multiple elements
234
+ * @param elements - Array of elements or CSS selector
235
+ * @param callback - Function that receives Motion instance for each element
236
+ * @param staggerDelay - Delay between each element animation (default: 0.1s)
237
+ */
238
+ declare function stagger(elements: HTMLElement[] | NodeListOf<HTMLElement> | string, callback: (motion: Motion, index: number) => void, staggerDelay?: number): Motion[];
239
+ /**
240
+ * Batch multiple elements with the same animation
241
+ * @param elements - Array of elements or CSS selector
242
+ * @param callback - Function that receives Motion instance
243
+ */
244
+ declare function batch(elements: HTMLElement[] | NodeListOf<HTMLElement> | string, callback: (motion: Motion) => void): Motion[];
245
+ /**
246
+ * Create a scroll-triggered entrance animation
247
+ * @param element - Element to animate
248
+ * @param options - Animation options
249
+ */
250
+ declare function scrollEntrance(element: HTMLElement, options?: AnimationOptions): Motion;
251
+ /**
252
+ * Create a hover animation using GSAP
253
+ * @param element - Element to animate on hover
254
+ * @param hoverVars - Animation properties on hover
255
+ * @param options - Animation options
256
+ */
257
+ declare function hover(element: HTMLElement, hoverVars: gsap.TweenVars, options?: AnimationOptions): () => void;
258
+ /**
259
+ * Create a parallax scroll effect
260
+ * @param element - Element to apply parallax
261
+ * @param speed - Parallax speed multiplier (default: 0.5)
262
+ */
263
+ declare function parallax(element: HTMLElement, speed?: number): gsap.core.Tween;
264
+ /**
265
+ * Create a reveal animation (commonly used for text/images)
266
+ * @param element - Element to reveal
267
+ * @param direction - Direction from which to reveal
268
+ * @param options - Animation options
269
+ */
270
+ declare function reveal(element: HTMLElement, direction?: 'left' | 'right' | 'top' | 'bottom', options?: AnimationOptions): Motion;
271
+
272
+ /**
273
+ * Predefined animation presets for common use cases
274
+ */
275
+ declare const presets: {
276
+ /**
277
+ * Quick and snappy animation
278
+ */
279
+ fast: AnimationOptions;
280
+ /**
281
+ * Standard animation speed
282
+ */
283
+ normal: AnimationOptions;
284
+ /**
285
+ * Slow and smooth animation
286
+ */
287
+ slow: AnimationOptions;
288
+ /**
289
+ * Bouncy entrance animation
290
+ */
291
+ bounce: AnimationOptions;
292
+ /**
293
+ * Spring-like animation
294
+ */
295
+ spring: AnimationOptions;
296
+ /**
297
+ * Smooth ease in and out
298
+ */
299
+ smooth: AnimationOptions;
300
+ /**
301
+ * Sharp entrance
302
+ */
303
+ sharp: AnimationOptions;
304
+ /**
305
+ * Elastic bounce effect
306
+ */
307
+ elastic: AnimationOptions;
308
+ };
309
+ /**
310
+ * Common easing functions
311
+ */
312
+ declare const easings: {
313
+ linear: string;
314
+ easeIn: string;
315
+ easeOut: string;
316
+ easeInOut: string;
317
+ smoothIn: string;
318
+ smoothOut: string;
319
+ smoothInOut: string;
320
+ bounceOut: string;
321
+ bounceIn: string;
322
+ bounceInOut: string;
323
+ elasticOut: string;
324
+ elasticIn: string;
325
+ backOut: string;
326
+ backIn: string;
327
+ circOut: string;
328
+ circIn: string;
329
+ expoOut: string;
330
+ expoIn: string;
331
+ };
22
332
 
23
- export { MotionCore, type MotionOptions, animate };
333
+ export { type AnimationOptions, type AnimationPreset, type FadeVariant, Motion, Motion as MotionCore, type ScrollAnimationOptions, type SlideDirection, animate, batch, easings, hover, parallax, presets, reveal, scrollEntrance, stagger };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{gsap as p}from"gsap";import{ScrollTrigger as m}from"gsap/ScrollTrigger";import{gsap as n}from"gsap";import{ScrollTrigger as l}from"gsap/ScrollTrigger";var o=class{tl;el;defaults={d:.8,e:"power4.out"};constructor(t){this.el=t,n.set(this.el,{opacity:0,y:20}),this.tl=n.timeline({paused:!0}),Promise.resolve().then(()=>{this.tl.scrollTrigger||this.tl.play()})}add(t,e){let{d:r,e:s,...a}=e||{};return this.tl.to(this.el,{...t,duration:r??this.defaults.d,ease:s??this.defaults.e,...a},">"),this}in(t){return this.add({opacity:1,y:0},t)}move(t,e,r){return this.add({x:t,y:e},r)}scale(t,e){return this.add({scale:t,ease:e?.e??"back.out(1.7)"},e)}wait(t){return this.tl.to({},{duration:t},">"),this}onScroll(t){return l.create({trigger:this.el,start:"top 85%",animation:this.tl,toggleActions:"play none none reverse",...t}),this}};function h(i,t){let e=t(),r=new o(i);setTimeout(()=>{e(r)},0)}typeof window<"u"&&p.registerPlugin(m);export{o as MotionCore,h as animate};
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 v={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)"}},w={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,w as easings,A as hover,O as parallax,v as presets,y as reveal,g as scrollEntrance,h as stagger};
package/package.json CHANGED
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "name": "@stellix-agency/motion",
3
- "publishConfig": { "access": "public" },
4
- "version": "1.0.0",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "version": "1.0.1",
5
7
  "description": "An intuitive GSAP wrapper for creating stunning animations with ease.",
6
8
  "author": "Stellix Agency",
7
9
  "license": "MIT",
@@ -15,7 +17,9 @@
15
17
  "main": "./dist/index.js",
16
18
  "module": "./dist/index.js",
17
19
  "types": "./dist/index.d.ts",
18
- "files": ["dist"],
20
+ "files": [
21
+ "dist"
22
+ ],
19
23
  "scripts": {
20
24
  "build": "tsup src/index.ts --format esm --dts --clean",
21
25
  "dev": "tsup src/index.ts --format esm --watch --dts"
@@ -30,4 +34,4 @@
30
34
  "gsap": "^3.14.2",
31
35
  "solid-js": "^1.9.11"
32
36
  }
33
- }
37
+ }