@hilux/ngx-motion 1.0.12 → 1.0.14
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 +99 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,6 +3,104 @@
|
|
|
3
3
|
WIP - Trigger and control angular animations with a Framer Motion like workflow in template HTML.
|
|
4
4
|
Generated with [Angular CLI](https://github.com/angular/angular-cli) version 19.1.0.
|
|
5
5
|
|
|
6
|
+
|
|
7
|
+
## Setup
|
|
8
|
+
|
|
9
|
+
Make sure you have provideAnimations() in app config
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
|
|
13
|
+
import { provideRouter, Router, withViewTransitions } from '@angular/router';
|
|
14
|
+
import { provideAnimations } from '@angular/platform-browser/animations';
|
|
15
|
+
import { routes } from './app.routes';
|
|
16
|
+
import { provideClientHydration, withEventReplay } from '@angular/platform-browser';
|
|
17
|
+
|
|
18
|
+
export const appConfig: ApplicationConfig = {
|
|
19
|
+
providers: [
|
|
20
|
+
provideZoneChangeDetection({ eventCoalescing: true }),
|
|
21
|
+
provideRouter(routes , withViewTransitions()),
|
|
22
|
+
provideClientHydration(withEventReplay()),
|
|
23
|
+
provideAnimations(),
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Import motin directive in your component
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
import { Component } from '@angular/core';
|
|
34
|
+
import { RouterOutlet, RouterLink, RouterLinkActive, ActivatedRoute, Router, NavigationEnd , NavigationStart} from '@angular/router';
|
|
35
|
+
import { MotionDirective } from '../../../../dist/ngx-motion/';
|
|
36
|
+
@Component({
|
|
37
|
+
selector: 'app-root',
|
|
38
|
+
imports: [
|
|
39
|
+
RouterOutlet,
|
|
40
|
+
MotionDirective
|
|
41
|
+
],
|
|
42
|
+
templateUrl: './app.component.html',
|
|
43
|
+
styleUrl: './app.component.scss',
|
|
44
|
+
standalone: true
|
|
45
|
+
})
|
|
46
|
+
export class AppComponent {
|
|
47
|
+
title = 'ngx-motion-demo';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Basic Example
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
<div
|
|
57
|
+
motion
|
|
58
|
+
[initial]="{
|
|
59
|
+
backgroundColor: 'red',
|
|
60
|
+
scale: 1,
|
|
61
|
+
transform: 'translateX(0px)'
|
|
62
|
+
}"
|
|
63
|
+
[animate]="{
|
|
64
|
+
backgroundColor: 'blue',
|
|
65
|
+
scale: 1,
|
|
66
|
+
transform: 'translateX(100px)'
|
|
67
|
+
}"
|
|
68
|
+
[duration]="'.5s'"
|
|
69
|
+
style="height: 100px; width: 100px; background-color: red"
|
|
70
|
+
>
|
|
71
|
+
Hello World
|
|
72
|
+
</div>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## Variant Example
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
this.foodVariants = {
|
|
80
|
+
egg: { opacity: 1, transform: 'translateX(0px)', backgroundColor: 'blue' },
|
|
81
|
+
apple: { opacity: 1, transform: 'translateX(100px)', backgroundColor: 'green' },
|
|
82
|
+
pasta: { opacity: 0.5, transform: 'scale(0.8)', backgroundColor: 'yellow' }
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
<div
|
|
86
|
+
motion
|
|
87
|
+
[variants]="foodVariants"
|
|
88
|
+
[animate]="currentFood"
|
|
89
|
+
style="
|
|
90
|
+
height: 100px;
|
|
91
|
+
width: 100px;
|
|
92
|
+
background-color: red;
|
|
93
|
+
position: absolute;
|
|
94
|
+
top: 0;
|
|
95
|
+
left: 0;
|
|
96
|
+
z-index: 100;
|
|
97
|
+
"
|
|
98
|
+
>
|
|
99
|
+
{{currentFood}}
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
|
|
6
104
|
## MotionDirective
|
|
7
105
|
|
|
8
106
|
- @Input() initial: any = {};
|
|
@@ -26,7 +124,7 @@ Generated with [Angular CLI](https://github.com/angular/angular-cli) version 19.
|
|
|
26
124
|
Current Limitations:
|
|
27
125
|
|
|
28
126
|
- staggerChildren not complete.
|
|
29
|
-
-
|
|
127
|
+
- Dynamic animate values must be generated in ts, you cant set directly in the animate value.
|
|
30
128
|
- InView offset not complete.
|
|
31
129
|
- Repeat & offset only apply to inView animations.
|
|
32
130
|
- exitDelay not complete.
|