ngx-easy-view-transitions 3.1.2 → 3.3.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
CHANGED
|
@@ -20,23 +20,19 @@ npm install ngx-easy-view-transitions
|
|
|
20
20
|
|
|
21
21
|
Required Angular version: `>=19.0.0`
|
|
22
22
|
|
|
23
|
-
You have to enable
|
|
23
|
+
You have to enable Angular's built-in view transitions in the Router using the [`withViewTransitions()`](https://angular.io/api/router/withViewTransitions#usage-notes) function.
|
|
24
24
|
|
|
25
25
|
```typescript
|
|
26
|
-
bootstrapApplication(AppComponent,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
provideRouter(appRoutes, withViewTransitions())
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
);
|
|
26
|
+
bootstrapApplication(AppComponent, {
|
|
27
|
+
providers: [provideRouter(appRoutes, withViewTransitions())]
|
|
28
|
+
});
|
|
33
29
|
```
|
|
34
30
|
|
|
35
31
|
## Usage
|
|
36
32
|
|
|
37
33
|
### Morph elements
|
|
38
34
|
|
|
39
|
-
To morph an element during navigation from the old to the new state use the `transitionName` directive and provide the same name on both pages.
|
|
35
|
+
To morph an element during navigation from the old to the new state, use the `transitionName` directive and provide the same name on both pages.
|
|
40
36
|
|
|
41
37
|
```typescript
|
|
42
38
|
import { TransitionNameDirective } from 'ngx-easy-view-transitions';
|
|
@@ -56,6 +52,13 @@ import { TransitionNameDirective } from 'ngx-easy-view-transitions';
|
|
|
56
52
|
|
|
57
53
|
Note that each `transitionName` must be unique for a page.
|
|
58
54
|
|
|
55
|
+
Transition names must be valid [`<custom-ident>`](https://developer.mozilla.org/en-US/docs/Web/CSS/custom-ident).
|
|
56
|
+
This library helps with this, by hashing the name to automatically comply.
|
|
57
|
+
|
|
58
|
+
For debugging purposes, you can show the original provided value as `data-original-view-transition-name` attribute by setting `showOriginalNameAttr` to `true`.
|
|
59
|
+
|
|
60
|
+
To opt out of hashing, set `preserveName` to `true`.
|
|
61
|
+
|
|
59
62
|
### Customize animations
|
|
60
63
|
|
|
61
64
|
Instead of morphing an element, you can provide custom animations for entering and leaving the view using the `inAnimation` and `outAnimation` inputs.
|
|
@@ -88,18 +91,18 @@ outAnimation = { keyframeName: 'fadeIn', duration: 600, reverse: true };
|
|
|
88
91
|
|
|
89
92
|
#### Using Keyframe array
|
|
90
93
|
|
|
91
|
-
When you want to use typed objects instead of CSS you can provide a [`Keyframe`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Keyframe_Formats) array:
|
|
94
|
+
When you want to use typed objects instead of CSS, you can provide a [`Keyframe`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Keyframe_Formats) array:
|
|
92
95
|
|
|
93
96
|
```typescript
|
|
94
97
|
const fadeIn: Keyframe[] = [
|
|
95
98
|
{
|
|
96
99
|
opacity: 0,
|
|
97
|
-
offset: 0
|
|
100
|
+
offset: 0
|
|
98
101
|
},
|
|
99
102
|
{
|
|
100
103
|
opacity: 1,
|
|
101
|
-
offset: 1
|
|
102
|
-
}
|
|
104
|
+
offset: 1
|
|
105
|
+
}
|
|
103
106
|
];
|
|
104
107
|
```
|
|
105
108
|
|
|
@@ -112,9 +115,26 @@ outAnimation = { keyframes: fadeIn, duration: 600, reverse: true };
|
|
|
112
115
|
<img transitionName="profile-picture" [inAnimation]="inAnimation" [outAnimation]="outAnimation" src="...">
|
|
113
116
|
```
|
|
114
117
|
|
|
118
|
+
#### Further customization
|
|
119
|
+
|
|
120
|
+
You can further customize the animation by passing standard
|
|
121
|
+
[CSS animation properties](https://developer.mozilla.org/de/docs/Web/CSS/Reference/Properties/animation),
|
|
122
|
+
such as `fill-mode`, `delay`, or `timing-function`.
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
animation = {
|
|
126
|
+
keyframeName: 'fadeIn',
|
|
127
|
+
duration: 600,
|
|
128
|
+
reverse: true,
|
|
129
|
+
fillMode: 'forwards',
|
|
130
|
+
timingFunction: 'ease-in',
|
|
131
|
+
delay: 100
|
|
132
|
+
};
|
|
133
|
+
```
|
|
134
|
+
|
|
115
135
|
### Built-In animations
|
|
116
136
|
|
|
117
|
-
To start faster there are some built-in animations available under `DefaultTransitions.*`.
|
|
137
|
+
To start faster, there are some built-in animations available under `DefaultTransitions.*`.
|
|
118
138
|
|
|
119
139
|
```typescript
|
|
120
140
|
import { DefaultTransitions } from 'ngx-easy-view-transitions';
|
|
@@ -122,7 +142,7 @@ import { DefaultTransitions } from 'ngx-easy-view-transitions';
|
|
|
122
142
|
inAnimation = { keyframes: DefaultTransitions.fadeInUp, duration: 600 };
|
|
123
143
|
```
|
|
124
144
|
|
|
125
|
-
You can
|
|
145
|
+
You can check them out in the [demo](https://derstimmler.github.io/ngx-easy-view-transitions/animations) and [here](https://github.com/DerStimmler/ngx-easy-view-transitions/blob/main/ngx-easy-view-transitions/src/lib/default-transitions.ts).
|
|
126
146
|
|
|
127
147
|
### Exclude element from view transitions
|
|
128
148
|
|
|
@@ -143,19 +163,25 @@ But you can also provide your own in and out animations by adding the `provideDe
|
|
|
143
163
|
|
|
144
164
|
In the following example, the default animation gets disabled:
|
|
145
165
|
|
|
166
|
+
<!-- prettier-ignore-start -->
|
|
146
167
|
```typescript
|
|
147
168
|
bootstrapApplication(AppComponent,
|
|
148
169
|
{
|
|
149
170
|
providers: [
|
|
150
171
|
provideRouter(appRoutes, withViewTransitions()),
|
|
151
172
|
provideDefaultViewTransition(
|
|
152
|
-
{
|
|
153
|
-
{
|
|
173
|
+
{keyframes: DefaultTransitions.none, duration: 0},
|
|
174
|
+
{keyframes: DefaultTransitions.none, duration: 0}
|
|
154
175
|
)
|
|
155
176
|
]
|
|
156
177
|
}
|
|
157
178
|
);
|
|
158
179
|
```
|
|
180
|
+
<!-- prettier-ignore-end -->
|
|
181
|
+
|
|
182
|
+
### Troubleshooting
|
|
183
|
+
|
|
184
|
+
If your elements flicker when navigating, try to set the `fillMode` to `forwards`.
|
|
159
185
|
|
|
160
186
|
## Development
|
|
161
187
|
|