@hilux/ngx-motion 1.1.2 → 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 +131 -57
- package/fesm2022/hilux-ngx-motion.mjs +2030 -0
- package/fesm2022/hilux-ngx-motion.mjs.map +1 -0
- package/package.json +35 -31
- package/types/hilux-ngx-motion.d.ts +777 -0
- package/ng-package.json +0 -7
- package/src/lib/components/motion-one-presence.component.ts +0 -116
- package/src/lib/constants/motion-defaults.constants.ts +0 -41
- package/src/lib/directives/motion-animate.directive.ts +0 -55
- package/src/lib/directives/motion-if.directive.ts +0 -138
- package/src/lib/directives/motion-one.directive.backup.ts +0 -1591
- package/src/lib/directives/motion-one.directive.ts +0 -1154
- package/src/lib/directives/motion-presence.directive.ts +0 -145
- package/src/lib/services/motion-animation-options.service.ts +0 -142
- package/src/lib/services/motion-animation.service.ts +0 -86
- package/src/lib/services/motion-browser-safe.ts +0 -64
- package/src/lib/services/motion-gesture.service.ts +0 -141
- package/src/lib/services/motion-inview.service.ts +0 -91
- package/src/lib/services/motion-one.service.ts +0 -424
- package/src/lib/services/motion-stagger.service.ts +0 -70
- package/src/lib/services/motion-timeline.service.ts +0 -182
- package/src/lib/types/motion-animation.types.ts +0 -46
- package/src/lib/utils/color.utils.ts +0 -54
- package/src/lib/utils/easing.utils.ts +0 -77
- package/src/lib/utils/index.ts +0 -7
- package/src/lib/utils/style-extraction.utils.ts +0 -70
- package/src/lib/utils/timing.utils.ts +0 -61
- package/src/lib/utils/transform.utils.ts +0 -112
- package/src/lib/utils/variant.utils.ts +0 -55
- package/src/public-api.ts +0 -21
- package/tsconfig.lib.json +0 -17
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -15
|
@@ -0,0 +1,777 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { AfterContentInit, ChangeDetectorRef, ElementRef, EventEmitter, NgZone, OnChanges, OnDestroy, OnInit, SimpleChanges, TemplateRef, ViewContainerRef, WritableSignal } from "@angular/core";
|
|
3
|
+
import { Observable } from "rxjs";
|
|
4
|
+
import { AnimationOptions } from "motion";
|
|
5
|
+
export interface MotionElement {
|
|
6
|
+
elementId: string;
|
|
7
|
+
getDuration(): number;
|
|
8
|
+
runInitAnimation(): void;
|
|
9
|
+
runExitAnimation(): void;
|
|
10
|
+
cancel(): void;
|
|
11
|
+
route?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class MotionOneService implements OnDestroy {
|
|
14
|
+
private document;
|
|
15
|
+
private platformId;
|
|
16
|
+
private ngZone;
|
|
17
|
+
private motionElements;
|
|
18
|
+
private readonly _scrollYProgress;
|
|
19
|
+
private removeScrollListener;
|
|
20
|
+
/**
|
|
21
|
+
* Page scroll progress (0-100). The scroll listener is only attached the
|
|
22
|
+
* first time this is read, so apps that never use it pay nothing.
|
|
23
|
+
*/
|
|
24
|
+
get scrollYProgress(): WritableSignal<number>;
|
|
25
|
+
totalExitDuration: number;
|
|
26
|
+
private exitAnimationsComplete;
|
|
27
|
+
private enterAnimationsComplete;
|
|
28
|
+
private activeExitAnimations;
|
|
29
|
+
private activeEnterAnimations;
|
|
30
|
+
constructor(document: Document, platformId: Object, ngZone: NgZone);
|
|
31
|
+
ngOnDestroy(): void;
|
|
32
|
+
/**
|
|
33
|
+
* TODO: In a future task, we want to use Angular framework's exit delay function
|
|
34
|
+
* to handle exit animations properly instead of this custom implementation.
|
|
35
|
+
*
|
|
36
|
+
* DISABLED: Exit duration calculation is disabled to prevent navigation blocking.
|
|
37
|
+
*/
|
|
38
|
+
private updateTotalExitDuration;
|
|
39
|
+
/**
|
|
40
|
+
* Passive scroll listener outside the Angular zone, throttled to one update per
|
|
41
|
+
* animation frame. The signal only changes when the rounded percentage changes,
|
|
42
|
+
* so templates reading it re-render at most once per percent.
|
|
43
|
+
*/
|
|
44
|
+
private ensureScrollListener;
|
|
45
|
+
private updateScrollProgress;
|
|
46
|
+
registerMotionElement(element: MotionElement): void;
|
|
47
|
+
unregisterMotionElement(element: MotionElement): void;
|
|
48
|
+
getMotionElements(): MotionElement[];
|
|
49
|
+
getAllElementsByRoute(route: string): MotionElement[];
|
|
50
|
+
cancelAllAnimations(): void;
|
|
51
|
+
runAllEnterAnimations(): void;
|
|
52
|
+
runAllExitAnimations(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Get an observable that emits true when all exit animations for a route are complete
|
|
55
|
+
* @param route The route to check for animation completion
|
|
56
|
+
* @returns Observable that emits true when animations are complete
|
|
57
|
+
*/
|
|
58
|
+
getExitAnimationsComplete(route: string): Observable<boolean>;
|
|
59
|
+
/**
|
|
60
|
+
* Get an observable that emits true when all enter animations for a route are complete
|
|
61
|
+
* @param route The route to check for animation completion
|
|
62
|
+
* @returns Observable that emits true when animations are complete
|
|
63
|
+
*/
|
|
64
|
+
getEnterAnimationsComplete(route: string): Observable<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Start tracking exit animations for a route
|
|
67
|
+
* @param route The route to track
|
|
68
|
+
*/
|
|
69
|
+
startExitAnimationsForRoute(route: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Start tracking enter animations for a route
|
|
72
|
+
* @param route The route to track
|
|
73
|
+
*/
|
|
74
|
+
startEnterAnimationsForRoute(route: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* Mark exit animations for a route as complete
|
|
77
|
+
* @param route The route to mark as complete
|
|
78
|
+
*/
|
|
79
|
+
private completeExitAnimationsForRoute;
|
|
80
|
+
/**
|
|
81
|
+
* Mark enter animations for a route as complete
|
|
82
|
+
* @param route The route to mark as complete
|
|
83
|
+
*/
|
|
84
|
+
private completeEnterAnimationsForRoute;
|
|
85
|
+
/**
|
|
86
|
+
* Check if exit animations for a route are complete
|
|
87
|
+
* @param route The route to check
|
|
88
|
+
* @returns True if animations are complete or not running
|
|
89
|
+
*/
|
|
90
|
+
areExitAnimationsComplete(route: string): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Check if enter animations for a route are complete
|
|
93
|
+
* @param route The route to check
|
|
94
|
+
* @returns True if animations are complete or not running
|
|
95
|
+
*/
|
|
96
|
+
areEnterAnimationsComplete(route: string): boolean;
|
|
97
|
+
runAllExitAnimationsForRoute(route: string): MotionElement[];
|
|
98
|
+
runAllEnterAnimationsForRoute(route: string): MotionElement[];
|
|
99
|
+
/**
|
|
100
|
+
* TODO: In a future task, we want to use Angular framework's exit delay function
|
|
101
|
+
* (e.g., route guards with canDeactivate or route transition animations)
|
|
102
|
+
* to handle exit animations properly instead of this custom implementation.
|
|
103
|
+
*
|
|
104
|
+
* DISABLED: Exit duration calculation is disabled to prevent navigation blocking.
|
|
105
|
+
* Navigation should be immediate and not wait for exit animations.
|
|
106
|
+
*/
|
|
107
|
+
getLongestExitDurationForRoute(route: string): number;
|
|
108
|
+
getLongestEnterDurationForRoute(route: string): number;
|
|
109
|
+
getLongestEnterDuration(): number;
|
|
110
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MotionOneService, never>;
|
|
111
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Thin wrapper around Motion's imperative API.
|
|
115
|
+
*
|
|
116
|
+
* - SSR-safe: every call is a no-op on the server.
|
|
117
|
+
* - Zone-friendly: animations and in-view observers run outside the Angular zone,
|
|
118
|
+
* so animation frames and observer callbacks don't trigger app-wide change
|
|
119
|
+
* detection in zone.js apps. (In zoneless apps this is free.)
|
|
120
|
+
*/
|
|
121
|
+
export declare class MotionAnimationService {
|
|
122
|
+
private readonly platformId;
|
|
123
|
+
private readonly ngZone;
|
|
124
|
+
private readonly isBrowser;
|
|
125
|
+
animate(target: any, keyframes: any, options?: any): any;
|
|
126
|
+
/**
|
|
127
|
+
* Observe when an element enters the viewport. Returns a stop function.
|
|
128
|
+
* The callback runs outside the Angular zone.
|
|
129
|
+
*/
|
|
130
|
+
inView(element: Element, onStart: (entry: IntersectionObserverEntry) => void | ((entry: IntersectionObserverEntry) => void), options?: {
|
|
131
|
+
root?: Element | Document;
|
|
132
|
+
margin?: string;
|
|
133
|
+
amount?: 'some' | 'all' | number;
|
|
134
|
+
}): () => void;
|
|
135
|
+
get easeIn(): (t: number) => number;
|
|
136
|
+
get easeOut(): (t: number) => number;
|
|
137
|
+
get easeInOut(): (t: number) => number;
|
|
138
|
+
stagger(duration: number, options?: any): any;
|
|
139
|
+
/**
|
|
140
|
+
* Returns an *ease* for spring-like easing in tween contexts (timelines,
|
|
141
|
+
* keyframe arrays). Motion's spring() is a generator that needs keyframes, not
|
|
142
|
+
* an easing factory, so calling it like this throws in Motion 12+; the previous
|
|
143
|
+
* implementation swallowed that and fell back to easeInOut, which we keep.
|
|
144
|
+
* Real springs are produced via `type: 'spring'` animation options instead.
|
|
145
|
+
*/
|
|
146
|
+
get spring(): (options?: {
|
|
147
|
+
stiffness?: number;
|
|
148
|
+
damping?: number;
|
|
149
|
+
}) => any;
|
|
150
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MotionAnimationService, never>;
|
|
151
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Shared type definitions for Motion One animations
|
|
155
|
+
*/
|
|
156
|
+
/**
|
|
157
|
+
* Transition configuration options similar to Framer Motion
|
|
158
|
+
*/
|
|
159
|
+
interface TransitionOptions {
|
|
160
|
+
duration?: number;
|
|
161
|
+
delay?: number;
|
|
162
|
+
ease?: string | number[] | {
|
|
163
|
+
type: 'spring';
|
|
164
|
+
stiffness?: number;
|
|
165
|
+
damping?: number;
|
|
166
|
+
};
|
|
167
|
+
repeat?: number | boolean;
|
|
168
|
+
repeatType?: 'loop' | 'mirror' | 'reverse' | 'forwards' | 'pingPong';
|
|
169
|
+
repeatDelay?: number;
|
|
170
|
+
staggerChildren?: number;
|
|
171
|
+
staggerDirection?: number;
|
|
172
|
+
when?: 'beforeChildren' | 'afterChildren' | 'together';
|
|
173
|
+
delayChildren?: number;
|
|
174
|
+
times?: number[];
|
|
175
|
+
/** Framer-style spring transition: { type: 'spring', stiffness, damping } */
|
|
176
|
+
type?: string;
|
|
177
|
+
stiffness?: number;
|
|
178
|
+
damping?: number;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Variant definition that can include transition properties
|
|
182
|
+
*/
|
|
183
|
+
interface VariantWithTransition {
|
|
184
|
+
[key: string]: any;
|
|
185
|
+
transition?: TransitionOptions;
|
|
186
|
+
at?: number;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Timeline step for orchestrated per-property animations
|
|
190
|
+
*/
|
|
191
|
+
interface TimelineStep {
|
|
192
|
+
prop: string;
|
|
193
|
+
keyframes?: any[] | any;
|
|
194
|
+
to?: any;
|
|
195
|
+
duration: number;
|
|
196
|
+
delay?: number;
|
|
197
|
+
ease?: string | number[] | {
|
|
198
|
+
type: 'spring';
|
|
199
|
+
stiffness?: number;
|
|
200
|
+
damping?: number;
|
|
201
|
+
};
|
|
202
|
+
atTime?: number;
|
|
203
|
+
times?: number[];
|
|
204
|
+
repeat?: number | boolean;
|
|
205
|
+
repeatType?: 'loop' | 'mirror' | 'reverse' | 'forwards' | 'pingPong';
|
|
206
|
+
repeatDelay?: number;
|
|
207
|
+
}
|
|
208
|
+
interface AnimationOptionsConfig {
|
|
209
|
+
targetState?: VariantWithTransition;
|
|
210
|
+
animateState?: VariantWithTransition;
|
|
211
|
+
staggerDelay?: number;
|
|
212
|
+
transition: TransitionOptions | Record<string, TransitionOptions>;
|
|
213
|
+
delay: number;
|
|
214
|
+
easing: string | number[] | {
|
|
215
|
+
type: 'spring';
|
|
216
|
+
stiffness?: number;
|
|
217
|
+
damping?: number;
|
|
218
|
+
};
|
|
219
|
+
duration: number;
|
|
220
|
+
repeat: boolean;
|
|
221
|
+
onComplete?: () => void;
|
|
222
|
+
}
|
|
223
|
+
declare class MotionAnimationOptionsService {
|
|
224
|
+
private motionAnimation;
|
|
225
|
+
constructor(motionAnimation: MotionAnimationService);
|
|
226
|
+
/**
|
|
227
|
+
* Build animation options from configuration
|
|
228
|
+
* Handles priority: stagger delay > state transition > global transition > defaults
|
|
229
|
+
*/
|
|
230
|
+
getAnimationOptions(config: AnimationOptionsConfig): AnimationOptions;
|
|
231
|
+
/**
|
|
232
|
+
* Get stagger value from transition configuration
|
|
233
|
+
*/
|
|
234
|
+
getStaggerValue(animateState?: VariantWithTransition, transition?: TransitionOptions | Record<string, TransitionOptions>, defaultStaggerChildren?: number): number;
|
|
235
|
+
/**
|
|
236
|
+
* Get stagger direction from transition configuration
|
|
237
|
+
*/
|
|
238
|
+
getStaggerDirection(animateState?: VariantWithTransition, transition?: TransitionOptions | Record<string, TransitionOptions>, defaultStaggerDirection?: number): number;
|
|
239
|
+
/**
|
|
240
|
+
* Get 'when' property from transition configuration
|
|
241
|
+
*/
|
|
242
|
+
getWhen(animateState?: VariantWithTransition, transition?: TransitionOptions | Record<string, TransitionOptions>): 'beforeChildren' | 'afterChildren' | 'together';
|
|
243
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MotionAnimationOptionsService, never>;
|
|
244
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
245
|
+
}
|
|
246
|
+
interface StaggerConfig {
|
|
247
|
+
childCount: number;
|
|
248
|
+
staggerValue: number;
|
|
249
|
+
staggerDirection: number;
|
|
250
|
+
delayChildren: number;
|
|
251
|
+
parentDelay: number;
|
|
252
|
+
}
|
|
253
|
+
declare class MotionStaggerService {
|
|
254
|
+
/**
|
|
255
|
+
* Calculate the delay for a specific child in a stagger sequence
|
|
256
|
+
*/
|
|
257
|
+
calculateChildDelay(index: number, config: StaggerConfig): number;
|
|
258
|
+
/**
|
|
259
|
+
* Calculate delays for all children in a stagger sequence
|
|
260
|
+
*/
|
|
261
|
+
calculateAllChildDelays(config: StaggerConfig): number[];
|
|
262
|
+
/**
|
|
263
|
+
* Calculate the total duration for a stagger animation sequence
|
|
264
|
+
*/
|
|
265
|
+
calculateTotalDuration(config: StaggerConfig): number;
|
|
266
|
+
/**
|
|
267
|
+
* Determine the stagger index based on direction
|
|
268
|
+
*/
|
|
269
|
+
getStaggerIndex(index: number, childCount: number, direction: number): number;
|
|
270
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MotionStaggerService, never>;
|
|
271
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
272
|
+
}
|
|
273
|
+
interface IntersectionObserverConfig {
|
|
274
|
+
root?: Element | null;
|
|
275
|
+
rootMargin?: string;
|
|
276
|
+
threshold?: number | number[];
|
|
277
|
+
}
|
|
278
|
+
declare class MotionInViewService {
|
|
279
|
+
private platformId;
|
|
280
|
+
constructor(platformId: Object);
|
|
281
|
+
/**
|
|
282
|
+
* Create an IntersectionObserver with the given configuration
|
|
283
|
+
*/
|
|
284
|
+
createObserver(callback: IntersectionObserverCallback, config?: IntersectionObserverConfig): IntersectionObserver | null;
|
|
285
|
+
/**
|
|
286
|
+
* Create a standard IntersectionObserver for runInView functionality
|
|
287
|
+
*/
|
|
288
|
+
createRunInViewObserver(element: HTMLElement, onEntry: () => void, onExit: () => void): IntersectionObserver | null;
|
|
289
|
+
/**
|
|
290
|
+
* Parse margin string (e.g., "0px", "10px 20px")
|
|
291
|
+
*/
|
|
292
|
+
parseMargin(margin: string): string;
|
|
293
|
+
/**
|
|
294
|
+
* Check if IntersectionObserver is supported
|
|
295
|
+
*/
|
|
296
|
+
isSupported(): boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Safely disconnect an observer
|
|
299
|
+
*/
|
|
300
|
+
disconnect(observer: IntersectionObserver | null | undefined): void;
|
|
301
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MotionInViewService, never>;
|
|
302
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
303
|
+
}
|
|
304
|
+
declare class MotionTimelineService {
|
|
305
|
+
private motionAnimation;
|
|
306
|
+
private readonly ngZone;
|
|
307
|
+
constructor(motionAnimation: MotionAnimationService);
|
|
308
|
+
/**
|
|
309
|
+
* Execute a timeline with orchestrated per-property animations
|
|
310
|
+
*/
|
|
311
|
+
runTimeline(element: HTMLElement, timeline: TimelineStep[], targetState: VariantWithTransition, baseDelay: number, duration: number, easing: any, repeat: boolean, onComplete?: () => void): {
|
|
312
|
+
controls: any[];
|
|
313
|
+
maxEnd: number;
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* Execute per-property animations with different timing for each property
|
|
317
|
+
*/
|
|
318
|
+
runPerPropertyAnimations(element: HTMLElement, targetState: VariantWithTransition, baseDelay: number, duration: number, easing: any, repeat: boolean, onComplete?: () => void): {
|
|
319
|
+
controls: any[];
|
|
320
|
+
maxEnd: number;
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* Check if a transition is a per-property map, e.g.
|
|
324
|
+
* `{ opacity: { duration: 0.2 }, x: { duration: 1, ease: 'ease-out' } }`.
|
|
325
|
+
*
|
|
326
|
+
* It must be a non-empty object whose keys are not transition options and whose
|
|
327
|
+
* values are all plain objects. Previously any transition without
|
|
328
|
+
* duration/delay/ease (such as `{ type: 'spring', stiffness: 200 }` or
|
|
329
|
+
* `{ staggerChildren: 0.1 }`) was misread as a per-property map.
|
|
330
|
+
*/
|
|
331
|
+
isPerPropertyTransition(transition: any): boolean;
|
|
332
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MotionTimelineService, never>;
|
|
333
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
334
|
+
}
|
|
335
|
+
interface GestureAnimationState {
|
|
336
|
+
isAnimating: boolean;
|
|
337
|
+
gestureType: 'hover' | 'tap' | 'focus' | null;
|
|
338
|
+
targetState: string | null;
|
|
339
|
+
controls: any;
|
|
340
|
+
startTime: number;
|
|
341
|
+
}
|
|
342
|
+
declare class MotionGestureService {
|
|
343
|
+
private gestureStates;
|
|
344
|
+
private readonly MIN_GESTURE_INTERVAL;
|
|
345
|
+
/**
|
|
346
|
+
* Check if a gesture should be allowed based on timing
|
|
347
|
+
* Prevents rapid-fire gesture triggers that cause aggressive spring behavior
|
|
348
|
+
*/
|
|
349
|
+
shouldAllowGesture(elementId: string, gestureType: 'hover' | 'tap' | 'focus'): boolean;
|
|
350
|
+
/**
|
|
351
|
+
* Register that a gesture animation is starting
|
|
352
|
+
*/
|
|
353
|
+
startGesture(elementId: string, gestureType: 'hover' | 'tap' | 'focus', targetState: string, controls: any): void;
|
|
354
|
+
/**
|
|
355
|
+
* Register that a gesture animation has ended
|
|
356
|
+
*/
|
|
357
|
+
endGesture(elementId: string): void;
|
|
358
|
+
/**
|
|
359
|
+
* Get the current gesture state for an element
|
|
360
|
+
*/
|
|
361
|
+
getGestureState(elementId: string): GestureAnimationState | undefined;
|
|
362
|
+
/**
|
|
363
|
+
* Cancel any ongoing gesture animation for an element
|
|
364
|
+
* Returns true if an animation was cancelled
|
|
365
|
+
*/
|
|
366
|
+
cancelGesture(elementId: string): boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Check if an element currently has an active gesture animation
|
|
369
|
+
*/
|
|
370
|
+
isGestureActive(elementId: string, gestureType?: 'hover' | 'tap' | 'focus'): boolean;
|
|
371
|
+
/**
|
|
372
|
+
* Clear all gesture state (useful for cleanup)
|
|
373
|
+
*/
|
|
374
|
+
clearElement(elementId: string): void;
|
|
375
|
+
/**
|
|
376
|
+
* Clear all gesture states
|
|
377
|
+
*/
|
|
378
|
+
clearAll(): void;
|
|
379
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MotionGestureService, never>;
|
|
380
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
381
|
+
}
|
|
382
|
+
export declare class MotionOneDirective implements OnInit, OnDestroy, OnChanges, AfterContentInit {
|
|
383
|
+
el: ElementRef;
|
|
384
|
+
private motionService;
|
|
385
|
+
private motionAnimation;
|
|
386
|
+
private animationOptions;
|
|
387
|
+
private staggerService;
|
|
388
|
+
private inViewService;
|
|
389
|
+
private timelineService;
|
|
390
|
+
private gestureService;
|
|
391
|
+
private platformId;
|
|
392
|
+
initial: VariantWithTransition | string;
|
|
393
|
+
animate: VariantWithTransition | string;
|
|
394
|
+
exit: VariantWithTransition | string;
|
|
395
|
+
inView: VariantWithTransition;
|
|
396
|
+
duration: number;
|
|
397
|
+
delay: number;
|
|
398
|
+
delayChildren: number;
|
|
399
|
+
repeat: boolean;
|
|
400
|
+
exitDelay: number;
|
|
401
|
+
easing: string | number[] | {
|
|
402
|
+
type: 'spring';
|
|
403
|
+
stiffness?: number;
|
|
404
|
+
damping?: number;
|
|
405
|
+
};
|
|
406
|
+
offset: string;
|
|
407
|
+
whileHover: VariantWithTransition;
|
|
408
|
+
staggerChildren: number;
|
|
409
|
+
staggerDirection: number;
|
|
410
|
+
whileTap: VariantWithTransition;
|
|
411
|
+
whileFocus: VariantWithTransition;
|
|
412
|
+
whileInView: VariantWithTransition;
|
|
413
|
+
runInView?: 'never' | 'once' | 'always';
|
|
414
|
+
variants: {
|
|
415
|
+
[key: string]: VariantWithTransition;
|
|
416
|
+
};
|
|
417
|
+
transition: TransitionOptions | Record<string, TransitionOptions>;
|
|
418
|
+
timeline: TimelineStep[] | undefined;
|
|
419
|
+
animationComplete: EventEmitter<void>;
|
|
420
|
+
restartAnimation(): void;
|
|
421
|
+
private restartTimer;
|
|
422
|
+
/**
|
|
423
|
+
* Nearest ancestor motionone directive (through component boundaries).
|
|
424
|
+
* Children register with it so a parent only orchestrates its *direct*
|
|
425
|
+
* motion children; grandchildren are orchestrated by their own parent.
|
|
426
|
+
*/
|
|
427
|
+
private parentMotion;
|
|
428
|
+
private readonly motionChildren;
|
|
429
|
+
/** Set once this directive has wired up its children (see initChildren). */
|
|
430
|
+
private childrenInitialized;
|
|
431
|
+
/**
|
|
432
|
+
* Values the element was last reset to via inline styles. Motion caches each
|
|
433
|
+
* element's last animated values, so after a reset it would otherwise animate
|
|
434
|
+
* from the stale cached value (i.e. not move at all). The next animation uses
|
|
435
|
+
* these as explicit `[from, to]` keyframes.
|
|
436
|
+
*/
|
|
437
|
+
private pendingFrom;
|
|
438
|
+
/** Direct motionone children, in registration (DOM) order. */
|
|
439
|
+
get childMotionDirectives(): MotionOneDirective[];
|
|
440
|
+
private controls;
|
|
441
|
+
private childrenControls;
|
|
442
|
+
elementId: string;
|
|
443
|
+
private hoverTimeout;
|
|
444
|
+
private observer?;
|
|
445
|
+
/** Stop function returned by Motion's inView() */
|
|
446
|
+
private inViewStop;
|
|
447
|
+
private readonly ngZone;
|
|
448
|
+
/** Removes gesture listeners attached in syncGestureListeners() */
|
|
449
|
+
private gestureCleanups;
|
|
450
|
+
private attachedGestures;
|
|
451
|
+
/** Removes a pending window mouseup/touchend listener from an in-progress press */
|
|
452
|
+
private pressEndCleanup;
|
|
453
|
+
private isChild;
|
|
454
|
+
private parentDirective;
|
|
455
|
+
private initialAnimationPlayed;
|
|
456
|
+
private _skipStartStylesApplication;
|
|
457
|
+
private staggerDelay;
|
|
458
|
+
private childrenCount;
|
|
459
|
+
private childIndex;
|
|
460
|
+
private isStaggeredChild;
|
|
461
|
+
private activeTimeouts;
|
|
462
|
+
get scrollProgress(): number;
|
|
463
|
+
private get isRunInViewEnabled();
|
|
464
|
+
private get runInViewRepeat();
|
|
465
|
+
constructor(el: ElementRef, motionService: MotionOneService, motionAnimation: MotionAnimationService, animationOptions: MotionAnimationOptionsService, staggerService: MotionStaggerService, inViewService: MotionInViewService, timelineService: MotionTimelineService, gestureService: MotionGestureService, platformId: Object);
|
|
466
|
+
/** Write styles synchronously and remember them as the next animation's start values. */
|
|
467
|
+
private setInlineStyles;
|
|
468
|
+
/** Animate this element, starting from any values it was just reset to. */
|
|
469
|
+
private animateSelf;
|
|
470
|
+
/**
|
|
471
|
+
* setTimeout outside the Angular zone (so it doesn't trigger change detection),
|
|
472
|
+
* tracked so it is cleared on destroy.
|
|
473
|
+
*/
|
|
474
|
+
private schedule;
|
|
475
|
+
private cancelScheduled;
|
|
476
|
+
/** Emit animationComplete back inside the zone, and only if someone is listening. */
|
|
477
|
+
private emitComplete;
|
|
478
|
+
ngOnInit(): void;
|
|
479
|
+
ngAfterContentInit(): void;
|
|
480
|
+
/** Wire up direct children and start whatever this directive orchestrates. Idempotent. */
|
|
481
|
+
private initChildren;
|
|
482
|
+
/**
|
|
483
|
+
* DI registers content projected into a component (`<ng-content>`) with the
|
|
484
|
+
* motionone around the component, not with the motionone the content is
|
|
485
|
+
* rendered inside. Framer Motion uses the rendered tree, so hand each such
|
|
486
|
+
* child to its nearest motionone ancestor in the DOM. Only ancestors inside
|
|
487
|
+
* this element count (content moved elsewhere, e.g. an overlay, stays put).
|
|
488
|
+
*/
|
|
489
|
+
private rehomeProjectedChildren;
|
|
490
|
+
/** Take over a child rehomed from an outer motionone (see rehomeProjectedChildren). */
|
|
491
|
+
private adoptChild;
|
|
492
|
+
/** Children this directive plays itself (in-view children play themselves when there's no stagger). */
|
|
493
|
+
private childrenToPlay;
|
|
494
|
+
/** Called by the parent when it's this child's turn in the stagger. */
|
|
495
|
+
private playAsChild;
|
|
496
|
+
setParent(parent: MotionOneDirective, index: number, totalChildren: number): void;
|
|
497
|
+
completeResetToInitial(): void;
|
|
498
|
+
forceResetToInitial(): void;
|
|
499
|
+
resetToInitialIfParentHasRunInView(): void;
|
|
500
|
+
parentExitViewportReset(): void;
|
|
501
|
+
private setupRunInViewObserver;
|
|
502
|
+
private handleViewportEntry;
|
|
503
|
+
private handleViewportExit;
|
|
504
|
+
applyStaggerToChildren(): void;
|
|
505
|
+
overrideDelay(delay: number): void;
|
|
506
|
+
runSelfAnimation(): void;
|
|
507
|
+
ngOnDestroy(): void;
|
|
508
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
509
|
+
private gestureListenersReady;
|
|
510
|
+
/**
|
|
511
|
+
* Attach only the gesture listeners this element actually uses, outside the
|
|
512
|
+
* Angular zone. Previously every directive bound six host listeners, each of
|
|
513
|
+
* which triggered app-wide change detection, and touchstart was non-passive.
|
|
514
|
+
*/
|
|
515
|
+
private syncGestureListeners;
|
|
516
|
+
private hasKeys;
|
|
517
|
+
/**
|
|
518
|
+
* Cancel running animations before writing reset styles. Motion's stop()
|
|
519
|
+
* commits the current value on the next frame, which overwrote the reset
|
|
520
|
+
* (an element leaving the view mid-animation froze half-way); cancel() doesn't.
|
|
521
|
+
*/
|
|
522
|
+
private cancelForReset;
|
|
523
|
+
private stopInView;
|
|
524
|
+
/** Reset elements to their initial styles with a single forced reflow for the whole batch. */
|
|
525
|
+
private resetToInitialStylesBatch;
|
|
526
|
+
onMouseEnter(): void;
|
|
527
|
+
onMouseLeave(): void;
|
|
528
|
+
onPress(event: Event): void;
|
|
529
|
+
onFocus(): void;
|
|
530
|
+
onBlur(): void;
|
|
531
|
+
applyInitialValues(): void;
|
|
532
|
+
private applyInitialStyles;
|
|
533
|
+
private applyAnimateStyles;
|
|
534
|
+
extractStyleProperties(variant: VariantWithTransition): Record<string, any>;
|
|
535
|
+
private getAnimationOptions;
|
|
536
|
+
private getStaggerValue;
|
|
537
|
+
private getStaggerDirection;
|
|
538
|
+
private getWhen;
|
|
539
|
+
/**
|
|
540
|
+
* Play animation TO a target state from current position
|
|
541
|
+
* Motion One will automatically use current animated values as the start
|
|
542
|
+
*/
|
|
543
|
+
private playAnimationToTarget;
|
|
544
|
+
/**
|
|
545
|
+
* Original playAnimation method - still used for initial animations and explicit start→end
|
|
546
|
+
*/
|
|
547
|
+
private playAnimation;
|
|
548
|
+
/**
|
|
549
|
+
* Animate to target from current position without explicit start state
|
|
550
|
+
* Motion One automatically interrupts any conflicting animations and preserves velocity
|
|
551
|
+
*/
|
|
552
|
+
private animateToTarget;
|
|
553
|
+
private continueAnimation;
|
|
554
|
+
private runPerPropertyAnimations;
|
|
555
|
+
private runTimeline;
|
|
556
|
+
private setupInViewAnimation;
|
|
557
|
+
runInViewAnimation(): void;
|
|
558
|
+
private setupWhileInViewAnimation;
|
|
559
|
+
private setupMotionOneInView;
|
|
560
|
+
/**
|
|
561
|
+
* Motion's inView() calls onStart on enter; returning a function makes it keep
|
|
562
|
+
* observing and call that function on leave. Returning nothing stops observing
|
|
563
|
+
* after the first entry, which is what runInView="once" wants.
|
|
564
|
+
*/
|
|
565
|
+
private setupStaggerParentInView;
|
|
566
|
+
private setupIndividualElementInView;
|
|
567
|
+
runInitAnimation(): void;
|
|
568
|
+
runExitAnimation(): Promise<void>;
|
|
569
|
+
cancel(): void;
|
|
570
|
+
getDuration(): number;
|
|
571
|
+
getKeyByValue(object: any, key: any): string | undefined;
|
|
572
|
+
triggerExitAnimation(): Promise<void>;
|
|
573
|
+
onMotionExit(): void;
|
|
574
|
+
getVariant(variant: VariantWithTransition | string): VariantWithTransition;
|
|
575
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MotionOneDirective, never>;
|
|
576
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<MotionOneDirective, "[motionone]", ["motionone"], {
|
|
577
|
+
"initial": {
|
|
578
|
+
"alias": "initial";
|
|
579
|
+
"required": false;
|
|
580
|
+
};
|
|
581
|
+
"animate": {
|
|
582
|
+
"alias": "animate";
|
|
583
|
+
"required": false;
|
|
584
|
+
};
|
|
585
|
+
"exit": {
|
|
586
|
+
"alias": "exit";
|
|
587
|
+
"required": false;
|
|
588
|
+
};
|
|
589
|
+
"inView": {
|
|
590
|
+
"alias": "inView";
|
|
591
|
+
"required": false;
|
|
592
|
+
};
|
|
593
|
+
"duration": {
|
|
594
|
+
"alias": "duration";
|
|
595
|
+
"required": false;
|
|
596
|
+
};
|
|
597
|
+
"delay": {
|
|
598
|
+
"alias": "delay";
|
|
599
|
+
"required": false;
|
|
600
|
+
};
|
|
601
|
+
"delayChildren": {
|
|
602
|
+
"alias": "delayChildren";
|
|
603
|
+
"required": false;
|
|
604
|
+
};
|
|
605
|
+
"repeat": {
|
|
606
|
+
"alias": "repeat";
|
|
607
|
+
"required": false;
|
|
608
|
+
};
|
|
609
|
+
"exitDelay": {
|
|
610
|
+
"alias": "exitDelay";
|
|
611
|
+
"required": false;
|
|
612
|
+
};
|
|
613
|
+
"easing": {
|
|
614
|
+
"alias": "easing";
|
|
615
|
+
"required": false;
|
|
616
|
+
};
|
|
617
|
+
"offset": {
|
|
618
|
+
"alias": "offset";
|
|
619
|
+
"required": false;
|
|
620
|
+
};
|
|
621
|
+
"whileHover": {
|
|
622
|
+
"alias": "whileHover";
|
|
623
|
+
"required": false;
|
|
624
|
+
};
|
|
625
|
+
"staggerChildren": {
|
|
626
|
+
"alias": "staggerChildren";
|
|
627
|
+
"required": false;
|
|
628
|
+
};
|
|
629
|
+
"staggerDirection": {
|
|
630
|
+
"alias": "staggerDirection";
|
|
631
|
+
"required": false;
|
|
632
|
+
};
|
|
633
|
+
"whileTap": {
|
|
634
|
+
"alias": "whileTap";
|
|
635
|
+
"required": false;
|
|
636
|
+
};
|
|
637
|
+
"whileFocus": {
|
|
638
|
+
"alias": "whileFocus";
|
|
639
|
+
"required": false;
|
|
640
|
+
};
|
|
641
|
+
"whileInView": {
|
|
642
|
+
"alias": "whileInView";
|
|
643
|
+
"required": false;
|
|
644
|
+
};
|
|
645
|
+
"runInView": {
|
|
646
|
+
"alias": "runInView";
|
|
647
|
+
"required": false;
|
|
648
|
+
};
|
|
649
|
+
"variants": {
|
|
650
|
+
"alias": "variants";
|
|
651
|
+
"required": false;
|
|
652
|
+
};
|
|
653
|
+
"transition": {
|
|
654
|
+
"alias": "transition";
|
|
655
|
+
"required": false;
|
|
656
|
+
};
|
|
657
|
+
"timeline": {
|
|
658
|
+
"alias": "timeline";
|
|
659
|
+
"required": false;
|
|
660
|
+
};
|
|
661
|
+
}, {
|
|
662
|
+
"animationComplete": "animationComplete";
|
|
663
|
+
}, never, never, true, never>;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Structural directive for animated presence with proper enter/exit lifecycle.
|
|
667
|
+
* Works with the existing motionone directive's animate and exit properties.
|
|
668
|
+
*
|
|
669
|
+
* Usage:
|
|
670
|
+
* ```html
|
|
671
|
+
* <div *motionIf="isVisible">
|
|
672
|
+
* <div motionone
|
|
673
|
+
* [initial]="{ opacity: 0, scale: 0.8 }"
|
|
674
|
+
* [animate]="{ opacity: 1, scale: 1 }"
|
|
675
|
+
* [exit]="{ opacity: 0, scale: 0.8 }">
|
|
676
|
+
* Content that animates in and out
|
|
677
|
+
* </div>
|
|
678
|
+
* </div>
|
|
679
|
+
* ```
|
|
680
|
+
*/
|
|
681
|
+
export declare class MotionIfDirective implements OnDestroy {
|
|
682
|
+
private templateRef;
|
|
683
|
+
private viewContainer;
|
|
684
|
+
private cdr;
|
|
685
|
+
private hasView;
|
|
686
|
+
private currentView;
|
|
687
|
+
private motionDirectives;
|
|
688
|
+
private exitTimeout;
|
|
689
|
+
constructor(templateRef: TemplateRef<any>, viewContainer: ViewContainerRef, cdr: ChangeDetectorRef);
|
|
690
|
+
/** True while exit animations run and the view is waiting to be removed. */
|
|
691
|
+
private exiting;
|
|
692
|
+
set motionIf(condition: boolean);
|
|
693
|
+
private enter;
|
|
694
|
+
/**
|
|
695
|
+
* Shown again while the exit animation was still running: keep the existing
|
|
696
|
+
* view (previously the pending timeout removed it anyway, so the content
|
|
697
|
+
* vanished while the condition was true) and animate back in.
|
|
698
|
+
*/
|
|
699
|
+
private cancelExit;
|
|
700
|
+
private exit;
|
|
701
|
+
private clearView;
|
|
702
|
+
private findMotionDirectives;
|
|
703
|
+
ngOnDestroy(): void;
|
|
704
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MotionIfDirective, never>;
|
|
705
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<MotionIfDirective, "[motionIf]", never, {
|
|
706
|
+
"motionIf": {
|
|
707
|
+
"alias": "motionIf";
|
|
708
|
+
"required": false;
|
|
709
|
+
};
|
|
710
|
+
}, {}, never, never, true, never>;
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* Enhanced structural directive for animated presence with proper lifecycle management.
|
|
714
|
+
* Automatically handles enter and exit animations for elements added/removed from DOM.
|
|
715
|
+
*
|
|
716
|
+
* Supports multiple integration patterns:
|
|
717
|
+
*
|
|
718
|
+
* Pattern 1 - Direct with motionone directive:
|
|
719
|
+
* ```html
|
|
720
|
+
* <div *motionPresence="show">
|
|
721
|
+
* <div motionone
|
|
722
|
+
* [initial]="{ opacity: 0 }"
|
|
723
|
+
* [animate]="{ opacity: 1 }"
|
|
724
|
+
* [exit]="{ opacity: 0 }">
|
|
725
|
+
* Content
|
|
726
|
+
* </div>
|
|
727
|
+
* </div>
|
|
728
|
+
* ```
|
|
729
|
+
*
|
|
730
|
+
* Pattern 2 - With animation callbacks:
|
|
731
|
+
* ```html
|
|
732
|
+
* <div *motionPresence="show; onEnter: handleEnter; onExit: handleExit">
|
|
733
|
+
* Content
|
|
734
|
+
* </div>
|
|
735
|
+
* ```
|
|
736
|
+
*/
|
|
737
|
+
export declare class MotionPresenceDirective {
|
|
738
|
+
private templateRef;
|
|
739
|
+
private viewContainer;
|
|
740
|
+
private cdr;
|
|
741
|
+
private hasView;
|
|
742
|
+
private currentView;
|
|
743
|
+
private exitTimeout;
|
|
744
|
+
private destroyRef;
|
|
745
|
+
motionPresenceOnEnter?: () => void;
|
|
746
|
+
motionPresenceOnExit?: () => Promise<void>;
|
|
747
|
+
constructor(templateRef: TemplateRef<any>, viewContainer: ViewContainerRef, cdr: ChangeDetectorRef);
|
|
748
|
+
/** True while exit animations run. Bumped exitId cancels an exit in progress. */
|
|
749
|
+
private exiting;
|
|
750
|
+
private exitId;
|
|
751
|
+
set motionPresence(condition: boolean);
|
|
752
|
+
private enter;
|
|
753
|
+
/**
|
|
754
|
+
* Shown again during the exit animation: keep the view and animate back in.
|
|
755
|
+
* Previously the in-flight exit still cleared the view afterwards, so the
|
|
756
|
+
* content disappeared while the condition was true.
|
|
757
|
+
*/
|
|
758
|
+
private cancelExit;
|
|
759
|
+
private exit;
|
|
760
|
+
private findMotionDirectives;
|
|
761
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MotionPresenceDirective, never>;
|
|
762
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<MotionPresenceDirective, "[motionPresence]", never, {
|
|
763
|
+
"motionPresenceOnEnter": {
|
|
764
|
+
"alias": "motionPresenceOnEnter";
|
|
765
|
+
"required": false;
|
|
766
|
+
};
|
|
767
|
+
"motionPresenceOnExit": {
|
|
768
|
+
"alias": "motionPresenceOnExit";
|
|
769
|
+
"required": false;
|
|
770
|
+
};
|
|
771
|
+
"motionPresence": {
|
|
772
|
+
"alias": "motionPresence";
|
|
773
|
+
"required": false;
|
|
774
|
+
};
|
|
775
|
+
}, {}, never, never, true, never>;
|
|
776
|
+
}
|
|
777
|
+
export type { TimelineStep, TransitionOptions, VariantWithTransition };
|