angular-movement 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -33
- package/fesm2022/angular-movement.mjs +509 -119
- package/fesm2022/angular-movement.mjs.map +1 -1
- package/package.json +3 -2
- package/types/angular-movement.d.ts +95 -16
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "angular-movement",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "Angular animation directives — presets, custom keyframes, spring physics, scroll & parallax.",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"angular",
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
"license": "MIT",
|
|
17
18
|
"repository": {
|
|
18
19
|
"type": "git",
|
|
19
|
-
"url": "https://github.com/Andersseen/angular-movement.git"
|
|
20
|
+
"url": "git+https://github.com/Andersseen/angular-movement.git"
|
|
20
21
|
},
|
|
21
22
|
"homepage": "https://github.com/Andersseen/angular-movement#readme",
|
|
22
23
|
"bugs": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
2
|
import { InjectionToken, OnDestroy, OnInit, EnvironmentProviders } from '@angular/core';
|
|
3
3
|
|
|
4
|
-
type MovePreset = 'fade-up' | 'fade-down' | 'fade-left' | 'fade-right' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'zoom-in' | 'zoom-out' | 'flip-x' | 'flip-y' | 'bounce-in' | 'blur-in' | 'spin' | 'pulse' | 'none';
|
|
4
|
+
type MovePreset = 'fade-up' | 'fade-down' | 'fade-left' | 'fade-right' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'zoom-in' | 'zoom-out' | 'flip-x' | 'flip-y' | 'bounce-in' | 'blur-in' | 'spin' | 'pulse' | 'shake' | 'swing' | 'wobble' | 'rubber-band' | 'heart-beat' | 'tada' | 'jello' | 'light-speed' | 'roll-in' | 'none';
|
|
5
5
|
type MoveValuePair = readonly number[];
|
|
6
6
|
interface MoveSpring {
|
|
7
7
|
stiffness?: number;
|
|
@@ -20,6 +20,7 @@ interface MoveKeyframes {
|
|
|
20
20
|
rotateX?: MoveValuePair;
|
|
21
21
|
rotateY?: MoveValuePair;
|
|
22
22
|
blur?: MoveValuePair;
|
|
23
|
+
[key: string]: MoveValuePair | undefined;
|
|
23
24
|
}
|
|
24
25
|
type MoveVariant = MoveKeyframes & {
|
|
25
26
|
spring?: MoveSpring;
|
|
@@ -30,6 +31,7 @@ type MoveVariant = MoveKeyframes & {
|
|
|
30
31
|
interface MovePresetDefinition {
|
|
31
32
|
enter: MoveKeyframes;
|
|
32
33
|
leave: MoveKeyframes;
|
|
34
|
+
loop?: MoveKeyframes;
|
|
33
35
|
}
|
|
34
36
|
interface MoveKeyframeState {
|
|
35
37
|
opacity?: number;
|
|
@@ -42,6 +44,7 @@ interface MoveKeyframeState {
|
|
|
42
44
|
rotateX?: number;
|
|
43
45
|
rotateY?: number;
|
|
44
46
|
blur?: number;
|
|
47
|
+
[key: string]: number | undefined;
|
|
45
48
|
}
|
|
46
49
|
interface MoveAnimationConfig {
|
|
47
50
|
initial?: MoveKeyframeState;
|
|
@@ -348,6 +351,89 @@ declare class MoveParallaxDirective implements OnInit, OnDestroy {
|
|
|
348
351
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<MoveParallaxDirective, "[moveParallax]", ["moveParallax"], { "moveParallax": { "alias": "moveParallax"; "required": false; "isSignal": true; }; "moveParallaxAxis": { "alias": "moveParallaxAxis"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
349
352
|
}
|
|
350
353
|
|
|
354
|
+
declare class MoveLoopDirective implements OnDestroy, OnInit {
|
|
355
|
+
#private;
|
|
356
|
+
readonly moveLoop: _angular_core.InputSignal<MovePreset | MoveKeyframes>;
|
|
357
|
+
readonly moveDuration: _angular_core.InputSignal<number | undefined>;
|
|
358
|
+
readonly moveEasing: _angular_core.InputSignal<string | undefined>;
|
|
359
|
+
readonly moveDelay: _angular_core.InputSignal<number | undefined>;
|
|
360
|
+
readonly moveDisabled: _angular_core.InputSignal<boolean | undefined>;
|
|
361
|
+
readonly moveSpring: _angular_core.InputSignal<MoveSpring | undefined>;
|
|
362
|
+
ngOnInit(): void;
|
|
363
|
+
ngOnDestroy(): void;
|
|
364
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MoveLoopDirective, never>;
|
|
365
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<MoveLoopDirective, "[moveLoop]", never, { "moveLoop": { "alias": "moveLoop"; "required": false; "isSignal": true; }; "moveDuration": { "alias": "moveDuration"; "required": false; "isSignal": true; }; "moveEasing": { "alias": "moveEasing"; "required": false; "isSignal": true; }; "moveDelay": { "alias": "moveDelay"; "required": false; "isSignal": true; }; "moveDisabled": { "alias": "moveDisabled"; "required": false; "isSignal": true; }; "moveSpring": { "alias": "moveSpring"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
declare class MoveTargetDirective implements OnDestroy {
|
|
369
|
+
#private;
|
|
370
|
+
readonly moveTarget: _angular_core.InputSignal<boolean>;
|
|
371
|
+
readonly moveFrames: _angular_core.InputSignal<MoveKeyframes>;
|
|
372
|
+
readonly moveDuration: _angular_core.InputSignalWithTransform<number | undefined, unknown>;
|
|
373
|
+
readonly moveEasing: _angular_core.InputSignal<string | undefined>;
|
|
374
|
+
readonly moveDelay: _angular_core.InputSignalWithTransform<number | undefined, unknown>;
|
|
375
|
+
readonly moveSpring: _angular_core.InputSignal<MoveSpring | undefined>;
|
|
376
|
+
readonly moveDisabled: _angular_core.InputSignal<boolean | undefined>;
|
|
377
|
+
readonly moveReverseDuration: _angular_core.InputSignalWithTransform<number | undefined, unknown>;
|
|
378
|
+
readonly moveReverseEasing: _angular_core.InputSignal<string | undefined>;
|
|
379
|
+
ngOnDestroy(): void;
|
|
380
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<MoveTargetDirective, never>;
|
|
381
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<MoveTargetDirective, "[moveTarget]", never, { "moveTarget": { "alias": "moveTarget"; "required": true; "isSignal": true; }; "moveFrames": { "alias": "moveFrames"; "required": true; "isSignal": true; }; "moveDuration": { "alias": "moveDuration"; "required": false; "isSignal": true; }; "moveEasing": { "alias": "moveEasing"; "required": false; "isSignal": true; }; "moveDelay": { "alias": "moveDelay"; "required": false; "isSignal": true; }; "moveSpring": { "alias": "moveSpring"; "required": false; "isSignal": true; }; "moveDisabled": { "alias": "moveDisabled"; "required": false; "isSignal": true; }; "moveReverseDuration": { "alias": "moveReverseDuration"; "required": false; "isSignal": true; }; "moveReverseEasing": { "alias": "moveReverseEasing"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
interface MovementConfig {
|
|
385
|
+
duration: number;
|
|
386
|
+
easing: string;
|
|
387
|
+
delay: number;
|
|
388
|
+
disabled: boolean;
|
|
389
|
+
iterations?: number;
|
|
390
|
+
}
|
|
391
|
+
declare const MOVEMENT_DEFAULTS: MovementConfig;
|
|
392
|
+
declare const MOVEMENT_CONFIG: InjectionToken<MovementConfig>;
|
|
393
|
+
|
|
394
|
+
type MovePhase = 'enter' | 'leave' | 'loop';
|
|
395
|
+
type MoveDirectiveInput = MovePreset | MoveKeyframes;
|
|
396
|
+
interface MoveInputOverrides {
|
|
397
|
+
duration?: number;
|
|
398
|
+
easing?: string;
|
|
399
|
+
delay?: number;
|
|
400
|
+
disabled?: boolean;
|
|
401
|
+
iterations?: number;
|
|
402
|
+
}
|
|
403
|
+
declare function resolveMovementConfig(defaults: MovementConfig, overrides: MoveInputOverrides, reducedMotion: boolean): MovementConfig;
|
|
404
|
+
declare function resolveMoveFrames(value: MoveDirectiveInput, phase: MovePhase): MoveKeyframes;
|
|
405
|
+
declare function prefersReducedMotion(documentRef: Document): boolean;
|
|
406
|
+
/**
|
|
407
|
+
* Reverses all keyframe value arrays in a MoveKeyframes object.
|
|
408
|
+
* Used by hover and tap directives to animate back to the original state.
|
|
409
|
+
*/
|
|
410
|
+
declare function reverseFrames(frames: MoveKeyframes): MoveKeyframes;
|
|
411
|
+
/**
|
|
412
|
+
* Applies the first keyframe values as inline styles to an element.
|
|
413
|
+
* Used by in-view and text directives to set the initial (hidden) state
|
|
414
|
+
* before the IntersectionObserver triggers the animation.
|
|
415
|
+
*/
|
|
416
|
+
declare function applyInitialStyles(el: HTMLElement, frames: MoveKeyframes): void;
|
|
417
|
+
/**
|
|
418
|
+
* Clears all inline styles set by `applyInitialStyles`.
|
|
419
|
+
* Called just before WAAPI animates so it can take full control.
|
|
420
|
+
*/
|
|
421
|
+
declare function clearInitialStyles(el: HTMLElement): void;
|
|
422
|
+
/**
|
|
423
|
+
* Validates MoveSpring configuration and returns sanitized values.
|
|
424
|
+
* Warns in development mode for invalid values.
|
|
425
|
+
*/
|
|
426
|
+
declare function validateSpring(spring: MoveSpring | undefined): MoveSpring | undefined;
|
|
427
|
+
/**
|
|
428
|
+
* Validates scroll offset string format "elFraction viewFraction".
|
|
429
|
+
* Returns true if valid, warns in dev mode if invalid.
|
|
430
|
+
*/
|
|
431
|
+
declare function isValidScrollOffset(offset: string): boolean;
|
|
432
|
+
/**
|
|
433
|
+
* Validates drag elastic factor. Must be between 0 and 1.
|
|
434
|
+
*/
|
|
435
|
+
declare function validateDragElastic(elastic: number): number;
|
|
436
|
+
|
|
351
437
|
/**
|
|
352
438
|
* SmoothScrollService — Lenis-inspired smooth scroll for Angular.
|
|
353
439
|
*
|
|
@@ -395,25 +481,17 @@ interface AnimationControls {
|
|
|
395
481
|
readonly finished: Promise<void>;
|
|
396
482
|
}
|
|
397
483
|
|
|
398
|
-
interface MovementConfig {
|
|
399
|
-
duration: number;
|
|
400
|
-
easing: string;
|
|
401
|
-
delay: number;
|
|
402
|
-
disabled: boolean;
|
|
403
|
-
}
|
|
404
|
-
declare const MOVEMENT_DEFAULTS: MovementConfig;
|
|
405
|
-
declare const MOVEMENT_CONFIG: InjectionToken<MovementConfig>;
|
|
406
|
-
|
|
407
484
|
interface PlayAnimationOptions {
|
|
408
485
|
config?: MovementConfig;
|
|
409
486
|
spring?: MoveSpring;
|
|
410
487
|
delay?: number;
|
|
411
488
|
disabled?: boolean;
|
|
489
|
+
iterations?: number;
|
|
412
490
|
onDone?: () => void;
|
|
413
491
|
}
|
|
414
492
|
declare class AnimationEngine {
|
|
415
493
|
#private;
|
|
416
|
-
play(host:
|
|
494
|
+
play(host: Element, frames: MoveKeyframes, options?: PlayAnimationOptions): AnimationControls | null;
|
|
417
495
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<AnimationEngine, never>;
|
|
418
496
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<AnimationEngine>;
|
|
419
497
|
}
|
|
@@ -423,9 +501,10 @@ declare class SpringPlayer implements AnimationControls {
|
|
|
423
501
|
private readonly host;
|
|
424
502
|
private readonly frames;
|
|
425
503
|
private readonly delay;
|
|
504
|
+
private readonly iterations;
|
|
426
505
|
private readonly onDone?;
|
|
427
506
|
readonly finished: Promise<void>;
|
|
428
|
-
constructor(host:
|
|
507
|
+
constructor(host: Element, frames: MoveKeyframes, userConfig: MoveSpring, delay: number, iterations?: number, onDone?: (() => void) | undefined);
|
|
429
508
|
play(): void;
|
|
430
509
|
pause(): void;
|
|
431
510
|
cancel(): void;
|
|
@@ -436,7 +515,7 @@ declare class SpringPlayer implements AnimationControls {
|
|
|
436
515
|
declare class WaapiPlayer implements AnimationControls {
|
|
437
516
|
#private;
|
|
438
517
|
readonly finished: Promise<void>;
|
|
439
|
-
constructor(host:
|
|
518
|
+
constructor(host: Element, frames: MoveKeyframes, config: MovementConfig, onDone?: () => void);
|
|
440
519
|
play(): void;
|
|
441
520
|
pause(): void;
|
|
442
521
|
cancel(): void;
|
|
@@ -449,7 +528,7 @@ declare const MOVE_PRESETS: Record<MovePreset, MovePresetDefinition>;
|
|
|
449
528
|
type MovementConfigInput = Partial<MovementConfig>;
|
|
450
529
|
declare function provideMovement(config?: MovementConfigInput): EnvironmentProviders;
|
|
451
530
|
|
|
452
|
-
declare const MOVEMENT_DIRECTIVES: readonly [typeof MoveEnterDirective, typeof MoveLeaveDirective, typeof MoveAnimateDirective, typeof MoveHoverDirective, typeof MoveTapDirective, typeof MoveVariantsDirective, typeof MoveStaggerDirective, typeof MoveLayoutDirective, typeof MoveScrollDirective, typeof MovePresenceDirective, typeof MoveDragDirective, typeof MoveInViewDirective, typeof MoveTextDirective, typeof MoveSmoothScrollDirective, typeof MoveFocusDirective, typeof MoveParallaxDirective, typeof MoveAnimationDirective];
|
|
531
|
+
declare const MOVEMENT_DIRECTIVES: readonly [typeof MoveEnterDirective, typeof MoveLeaveDirective, typeof MoveAnimateDirective, typeof MoveHoverDirective, typeof MoveTapDirective, typeof MoveVariantsDirective, typeof MoveStaggerDirective, typeof MoveLayoutDirective, typeof MoveScrollDirective, typeof MovePresenceDirective, typeof MoveDragDirective, typeof MoveInViewDirective, typeof MoveTextDirective, typeof MoveSmoothScrollDirective, typeof MoveFocusDirective, typeof MoveParallaxDirective, typeof MoveAnimationDirective, typeof MoveLoopDirective, typeof MoveTargetDirective];
|
|
453
532
|
|
|
454
|
-
export { AnimationEngine, MOVEMENT_CONFIG, MOVEMENT_DEFAULTS, MOVEMENT_DIRECTIVES, MOVE_PRESENCE_PARENT, MOVE_PRESETS, MOVE_STAGGER_PARENT, MOVE_VARIANTS_PARENT, MoveAnimateDirective, MoveAnimationDirective, MoveDragDirective, MoveEnterDirective, MoveFocusDirective, MoveHoverDirective, MoveInViewDirective, MoveLayoutDirective, MoveLeaveDirective, MoveParallaxDirective, MovePresenceDirective, MoveScrollDirective, MoveSmoothScrollDirective, MoveStaggerDirective, MoveTapDirective, MoveTextDirective, MoveVariantsDirective, SmoothScrollService, SpringPlayer, WaapiPlayer, provideMovement };
|
|
455
|
-
export type { AnimationControls, MoveAnimationConfig, MoveDragConstraints, MoveKeyframeState, MoveKeyframes, MovePresenceChild, MovePresenceProvider, MovePreset, MovePresetDefinition, MoveSpring, MoveStaggerDirection, MoveStaggerProvider, MoveValuePair, MoveVariant, MoveVariantsProvider, MovementConfig, MovementConfigInput, PlayAnimationOptions };
|
|
533
|
+
export { AnimationEngine, MOVEMENT_CONFIG, MOVEMENT_DEFAULTS, MOVEMENT_DIRECTIVES, MOVE_PRESENCE_PARENT, MOVE_PRESETS, MOVE_STAGGER_PARENT, MOVE_VARIANTS_PARENT, MoveAnimateDirective, MoveAnimationDirective, MoveDragDirective, MoveEnterDirective, MoveFocusDirective, MoveHoverDirective, MoveInViewDirective, MoveLayoutDirective, MoveLeaveDirective, MoveLoopDirective, MoveParallaxDirective, MovePresenceDirective, MoveScrollDirective, MoveSmoothScrollDirective, MoveStaggerDirective, MoveTapDirective, MoveTargetDirective, MoveTextDirective, MoveVariantsDirective, SmoothScrollService, SpringPlayer, WaapiPlayer, applyInitialStyles, clearInitialStyles, isValidScrollOffset, prefersReducedMotion, provideMovement, resolveMoveFrames, resolveMovementConfig, reverseFrames, validateDragElastic, validateSpring };
|
|
534
|
+
export type { AnimationControls, MoveAnimationConfig, MoveDirectiveInput, MoveDragConstraints, MoveInputOverrides, MoveKeyframeState, MoveKeyframes, MovePhase, MovePresenceChild, MovePresenceProvider, MovePreset, MovePresetDefinition, MoveSpring, MoveStaggerDirection, MoveStaggerProvider, MoveValuePair, MoveVariant, MoveVariantsProvider, MovementConfig, MovementConfigInput, PlayAnimationOptions };
|