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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, ElementRef, RendererFactory2, Directive, Injectable, input, Renderer2, effect, provideAppInitializer } from '@angular/core';
2
+ import { inject, ElementRef, RendererFactory2, Directive, Injectable, input, Renderer2, computed, effect, untracked, provideAppInitializer } from '@angular/core';
3
3
  import { DOCUMENT } from '@angular/common';
4
4
 
5
5
  const none = [];
@@ -7,525 +7,525 @@ const scaleIn = [
7
7
  {
8
8
  opacity: 0,
9
9
  transform: 'scale(0.5)',
10
- offset: 0,
10
+ offset: 0
11
11
  },
12
12
  {
13
13
  opacity: 1,
14
14
  transform: 'scale(1)',
15
- offset: 1,
16
- },
15
+ offset: 1
16
+ }
17
17
  ];
18
18
  const scaleOut = [
19
19
  {
20
20
  opacity: 1,
21
21
  transform: 'scale(1)',
22
- offset: 0,
22
+ offset: 0
23
23
  },
24
24
  {
25
25
  opacity: 0,
26
26
  transform: 'scale(0.5)',
27
- offset: 1,
28
- },
27
+ offset: 1
28
+ }
29
29
  ];
30
30
  const fadeIn = [
31
31
  {
32
32
  opacity: 0,
33
- offset: 0,
33
+ offset: 0
34
34
  },
35
35
  {
36
36
  opacity: 1,
37
- offset: 1,
38
- },
37
+ offset: 1
38
+ }
39
39
  ];
40
40
  const fadeOut = [
41
41
  {
42
42
  opacity: 1,
43
- offset: 0,
43
+ offset: 0
44
44
  },
45
45
  {
46
46
  opacity: 0,
47
- offset: 1,
48
- },
47
+ offset: 1
48
+ }
49
49
  ];
50
50
  const fadeInUp = [
51
51
  {
52
52
  opacity: 0,
53
53
  transform: 'translate(0, 100%)',
54
- offset: 0,
54
+ offset: 0
55
55
  },
56
56
  {
57
57
  opacity: 1,
58
58
  transform: 'translate(0, 0)',
59
- offset: 1,
60
- },
59
+ offset: 1
60
+ }
61
61
  ];
62
62
  const fadeOutUp = [
63
63
  {
64
64
  opacity: 1,
65
- offset: 0,
65
+ offset: 0
66
66
  },
67
67
  {
68
68
  opacity: 0,
69
69
  transform: 'translate(0, -100%)',
70
- offset: 1,
71
- },
70
+ offset: 1
71
+ }
72
72
  ];
73
73
  const fadeInDown = [
74
74
  {
75
75
  opacity: 0,
76
76
  transform: 'translate(0, -100%)',
77
- offset: 0,
77
+ offset: 0
78
78
  },
79
79
  {
80
80
  opacity: 1,
81
81
  transform: 'translate(0, 0)',
82
- offset: 1,
83
- },
82
+ offset: 1
83
+ }
84
84
  ];
85
85
  const fadeOutDown = [
86
86
  {
87
87
  opacity: 1,
88
- offset: 0,
88
+ offset: 0
89
89
  },
90
90
  {
91
91
  opacity: 0,
92
92
  transform: 'translate(0, 100%)',
93
- offset: 1,
94
- },
93
+ offset: 1
94
+ }
95
95
  ];
96
96
  const fadeInRight = [
97
97
  {
98
98
  opacity: 0,
99
99
  transform: 'translate(100%, 0)',
100
- offset: 0,
100
+ offset: 0
101
101
  },
102
102
  {
103
103
  opacity: 1,
104
104
  transform: 'translate(0, 0)',
105
- offset: 1,
106
- },
105
+ offset: 1
106
+ }
107
107
  ];
108
108
  const fadeOutRight = [
109
109
  {
110
110
  opacity: 1,
111
- offset: 0,
111
+ offset: 0
112
112
  },
113
113
  {
114
114
  opacity: 0,
115
115
  transform: 'translate(100%, 0)',
116
- offset: 1,
117
- },
116
+ offset: 1
117
+ }
118
118
  ];
119
119
  const fadeInLeft = [
120
120
  {
121
121
  opacity: 0,
122
122
  transform: 'translate(-100%, 0)',
123
- offset: 0,
123
+ offset: 0
124
124
  },
125
125
  {
126
126
  opacity: 1,
127
127
  transform: 'translate(0, 0)',
128
- offset: 1,
129
- },
128
+ offset: 1
129
+ }
130
130
  ];
131
131
  const fadeOutLeft = [
132
132
  {
133
133
  opacity: 1,
134
- offset: 0,
134
+ offset: 0
135
135
  },
136
136
  {
137
137
  opacity: 0,
138
138
  transform: 'translate(-100%, 0)',
139
- offset: 1,
140
- },
139
+ offset: 1
140
+ }
141
141
  ];
142
142
  const flipInX = [
143
143
  {
144
144
  opacity: 0,
145
145
  transform: 'rotateX(90deg)',
146
- offset: 0,
146
+ offset: 0
147
147
  },
148
148
  {
149
149
  opacity: 1,
150
150
  transform: 'rotateX(0)',
151
- offset: 1,
152
- },
151
+ offset: 1
152
+ }
153
153
  ];
154
154
  const flipOutX = [
155
155
  {
156
156
  opacity: 1,
157
157
  transform: 'rotateX(0)',
158
- offset: 0,
158
+ offset: 0
159
159
  },
160
160
  {
161
161
  opacity: 0,
162
162
  transform: 'rotateX(90deg)',
163
- offset: 1,
164
- },
163
+ offset: 1
164
+ }
165
165
  ];
166
166
  const flipInY = [
167
167
  {
168
168
  opacity: 0,
169
169
  transform: 'rotateY(90deg)',
170
- offset: 0,
170
+ offset: 0
171
171
  },
172
172
  {
173
173
  opacity: 1,
174
174
  transform: 'rotateY(0)',
175
- offset: 1,
176
- },
175
+ offset: 1
176
+ }
177
177
  ];
178
178
  const flipOutY = [
179
179
  {
180
180
  opacity: 1,
181
181
  transform: 'rotateY(0)',
182
- offset: 0,
182
+ offset: 0
183
183
  },
184
184
  {
185
185
  opacity: 0,
186
186
  transform: 'rotateY(90deg)',
187
- offset: 1,
188
- },
187
+ offset: 1
188
+ }
189
189
  ];
190
190
  const rotateIn = [
191
191
  {
192
192
  opacity: 0,
193
193
  transform: 'rotate(-180deg) scale(0.5)',
194
- offset: 0,
194
+ offset: 0
195
195
  },
196
196
  {
197
197
  opacity: 1,
198
198
  transform: 'rotate(0) scale(1)',
199
- offset: 1,
200
- },
199
+ offset: 1
200
+ }
201
201
  ];
202
202
  const rotateOut = [
203
203
  {
204
204
  opacity: 1,
205
205
  transform: 'rotate(0) scale(1)',
206
- offset: 0,
206
+ offset: 0
207
207
  },
208
208
  {
209
209
  opacity: 0,
210
210
  transform: 'rotate(180deg) scale(0.5)',
211
- offset: 1,
212
- },
211
+ offset: 1
212
+ }
213
213
  ];
214
214
  const bounceIn = [
215
215
  {
216
216
  opacity: 0,
217
217
  transform: 'scale(0.3)',
218
- offset: 0,
218
+ offset: 0
219
219
  },
220
220
  {
221
221
  opacity: 1,
222
222
  transform: 'scale(1.05)',
223
- offset: 0.6,
223
+ offset: 0.6
224
224
  },
225
225
  {
226
226
  opacity: 1,
227
227
  transform: 'scale(0.95)',
228
- offset: 0.8,
228
+ offset: 0.8
229
229
  },
230
230
  {
231
231
  opacity: 1,
232
232
  transform: 'scale(1)',
233
- offset: 1,
234
- },
233
+ offset: 1
234
+ }
235
235
  ];
236
236
  const bounceOut = [
237
237
  {
238
238
  opacity: 1,
239
239
  transform: 'scale(1)',
240
- offset: 0,
240
+ offset: 0
241
241
  },
242
242
  {
243
243
  opacity: 1,
244
244
  transform: 'scale(0.95)',
245
- offset: 0.2,
245
+ offset: 0.2
246
246
  },
247
247
  {
248
248
  opacity: 1,
249
249
  transform: 'scale(1.05)',
250
- offset: 0.4,
250
+ offset: 0.4
251
251
  },
252
252
  {
253
253
  opacity: 0,
254
254
  transform: 'scale(0.3)',
255
- offset: 1,
256
- },
255
+ offset: 1
256
+ }
257
257
  ];
258
258
  const blurIn = [
259
259
  {
260
260
  opacity: 0,
261
261
  transform: 'scale(1.2)',
262
262
  filter: 'blur(20px)',
263
- offset: 0,
263
+ offset: 0
264
264
  },
265
265
  {
266
266
  opacity: 1,
267
267
  transform: 'scale(1)',
268
268
  filter: 'blur(0px)',
269
- offset: 1,
270
- },
269
+ offset: 1
270
+ }
271
271
  ];
272
272
  const blurOut = [
273
273
  {
274
274
  opacity: 1,
275
275
  transform: 'scale(1)',
276
276
  filter: 'blur(0px)',
277
- offset: 0,
277
+ offset: 0
278
278
  },
279
279
  {
280
280
  opacity: 0,
281
281
  transform: 'scale(0.8)',
282
282
  filter: 'blur(20px)',
283
- offset: 1,
284
- },
283
+ offset: 1
284
+ }
285
285
  ];
286
286
  const perspectiveIn = [
287
287
  {
288
288
  opacity: 0,
289
289
  transform: 'perspective(1000px) rotateY(90deg)',
290
- offset: 0,
290
+ offset: 0
291
291
  },
292
292
  {
293
293
  opacity: 1,
294
294
  transform: 'perspective(1000px) rotateY(0deg)',
295
- offset: 1,
296
- },
295
+ offset: 1
296
+ }
297
297
  ];
298
298
  const perspectiveOut = [
299
299
  {
300
300
  opacity: 1,
301
301
  transform: 'perspective(1000px) rotateY(0deg)',
302
- offset: 0,
302
+ offset: 0
303
303
  },
304
304
  {
305
305
  opacity: 0,
306
306
  transform: 'perspective(1000px) rotateY(-90deg)',
307
- offset: 1,
308
- },
307
+ offset: 1
308
+ }
309
309
  ];
310
310
  const skewIn = [
311
311
  {
312
312
  opacity: 0,
313
313
  transform: 'translateX(-100%) skewX(30deg)',
314
- offset: 0,
314
+ offset: 0
315
315
  },
316
316
  {
317
317
  opacity: 1,
318
318
  transform: 'translateX(0) skewX(0deg)',
319
- offset: 1,
320
- },
319
+ offset: 1
320
+ }
321
321
  ];
322
322
  const skewOut = [
323
323
  {
324
324
  opacity: 1,
325
325
  transform: 'translateX(0) skewX(0deg)',
326
- offset: 0,
326
+ offset: 0
327
327
  },
328
328
  {
329
329
  opacity: 0,
330
330
  transform: 'translateX(100%) skewX(-30deg)',
331
- offset: 1,
332
- },
331
+ offset: 1
332
+ }
333
333
  ];
334
334
  const revealCircleIn = [
335
335
  {
336
336
  clipPath: 'circle(0% at 50% 50%)',
337
- offset: 0,
337
+ offset: 0
338
338
  },
339
339
  {
340
340
  clipPath: 'circle(150% at 50% 50%)',
341
- offset: 1,
342
- },
341
+ offset: 1
342
+ }
343
343
  ];
344
344
  const revealCircleOut = [
345
345
  {
346
346
  clipPath: 'circle(150% at 50% 50%)',
347
- offset: 0,
347
+ offset: 0
348
348
  },
349
349
  {
350
350
  clipPath: 'circle(0% at 50% 50%)',
351
- offset: 1,
352
- },
351
+ offset: 1
352
+ }
353
353
  ];
354
354
  const parallaxIn = [
355
355
  {
356
356
  opacity: 0,
357
357
  transform: 'translateZ(-300px) scale(2)',
358
- offset: 0,
358
+ offset: 0
359
359
  },
360
360
  {
361
361
  opacity: 1,
362
362
  transform: 'translateZ(0) scale(1)',
363
- offset: 1,
364
- },
363
+ offset: 1
364
+ }
365
365
  ];
366
366
  const parallaxOut = [
367
367
  {
368
368
  opacity: 1,
369
369
  transform: 'translateZ(0) scale(1)',
370
- offset: 0,
370
+ offset: 0
371
371
  },
372
372
  {
373
373
  opacity: 0,
374
374
  transform: 'translateZ(-300px) scale(0.8)',
375
- offset: 1,
376
- },
375
+ offset: 1
376
+ }
377
377
  ];
378
378
  const tiltIn = [
379
379
  {
380
380
  opacity: 0,
381
381
  transform: 'rotate(-15deg) translateY(50%)',
382
- offset: 0,
382
+ offset: 0
383
383
  },
384
384
  {
385
385
  opacity: 1,
386
386
  transform: 'rotate(0) translateY(0)',
387
- offset: 1,
388
- },
387
+ offset: 1
388
+ }
389
389
  ];
390
390
  const tiltOut = [
391
391
  {
392
392
  opacity: 1,
393
393
  transform: 'rotate(0) translateY(0)',
394
- offset: 0,
394
+ offset: 0
395
395
  },
396
396
  {
397
397
  opacity: 0,
398
398
  transform: 'rotate(15deg) translateY(-50%)',
399
- offset: 1,
400
- },
399
+ offset: 1
400
+ }
401
401
  ];
402
402
  const glitchIn = [
403
403
  {
404
404
  opacity: 0,
405
405
  transform: 'translate(0, 0)',
406
- offset: 0,
406
+ offset: 0
407
407
  },
408
408
  {
409
409
  opacity: 1,
410
410
  transform: 'translate(-2px, 2px)',
411
- offset: 0.2,
411
+ offset: 0.2
412
412
  },
413
413
  {
414
414
  opacity: 1,
415
415
  transform: 'translate(2px, -2px)',
416
- offset: 0.4,
416
+ offset: 0.4
417
417
  },
418
418
  {
419
419
  opacity: 1,
420
420
  transform: 'translate(-1px, 1px)',
421
- offset: 0.6,
421
+ offset: 0.6
422
422
  },
423
423
  {
424
424
  opacity: 1,
425
425
  transform: 'translate(1px, -1px)',
426
- offset: 0.8,
426
+ offset: 0.8
427
427
  },
428
428
  {
429
429
  opacity: 1,
430
430
  transform: 'translate(0, 0)',
431
- offset: 1,
432
- },
431
+ offset: 1
432
+ }
433
433
  ];
434
434
  const curtainIn = [
435
435
  {
436
436
  clipPath: 'inset(0 50% 0 50%)',
437
- offset: 0,
437
+ offset: 0
438
438
  },
439
439
  {
440
440
  clipPath: 'inset(0 0% 0 0%)',
441
- offset: 1,
442
- },
441
+ offset: 1
442
+ }
443
443
  ];
444
444
  const curtainOut = [
445
445
  {
446
446
  clipPath: 'inset(0 0% 0 0%)',
447
- offset: 0,
447
+ offset: 0
448
448
  },
449
449
  {
450
450
  clipPath: 'inset(0 50% 0 50%)',
451
- offset: 1,
452
- },
451
+ offset: 1
452
+ }
453
453
  ];
454
454
  const depthFlipIn = [
455
455
  {
456
456
  opacity: 0,
457
457
  transform: 'perspective(1200px) rotateX(-90deg) translateZ(-200px)',
458
- offset: 0,
458
+ offset: 0
459
459
  },
460
460
  {
461
461
  opacity: 1,
462
462
  transform: 'perspective(1200px) rotateX(0deg) translateZ(0)',
463
- offset: 1,
464
- },
463
+ offset: 1
464
+ }
465
465
  ];
466
466
  const depthFlipOut = [
467
467
  {
468
468
  opacity: 1,
469
469
  transform: 'perspective(1200px) rotateX(0deg) translateZ(0)',
470
- offset: 0,
470
+ offset: 0
471
471
  },
472
472
  {
473
473
  opacity: 0,
474
474
  transform: 'perspective(1200px) rotateX(90deg) translateZ(-200px)',
475
- offset: 1,
476
- },
475
+ offset: 1
476
+ }
477
477
  ];
478
478
  const distortWarpIn = [
479
479
  {
480
480
  opacity: 0,
481
481
  transform: 'skewX(20deg) scale(0.9)',
482
482
  filter: 'blur(10px)',
483
- offset: 0,
483
+ offset: 0
484
484
  },
485
485
  {
486
486
  opacity: 1,
487
487
  transform: 'skewX(0deg) scale(1)',
488
488
  filter: 'blur(0px)',
489
- offset: 1,
490
- },
489
+ offset: 1
490
+ }
491
491
  ];
492
492
  const distortWarpOut = [
493
493
  {
494
494
  opacity: 1,
495
495
  transform: 'skewX(0deg) scale(1)',
496
496
  filter: 'blur(0px)',
497
- offset: 0,
497
+ offset: 0
498
498
  },
499
499
  {
500
500
  opacity: 0,
501
501
  transform: 'skewX(-20deg) scale(0.9)',
502
502
  filter: 'blur(10px)',
503
- offset: 1,
504
- },
503
+ offset: 1
504
+ }
505
505
  ];
506
506
  const coverFlipIn = [
507
507
  {
508
508
  opacity: 0,
509
509
  transform: 'perspective(800px) rotateY(-12deg) translateX(-8px)',
510
- offset: 0,
510
+ offset: 0
511
511
  },
512
512
  {
513
513
  opacity: 1,
514
514
  transform: 'perspective(800px) rotateY(0deg) translateX(0)',
515
- offset: 1,
516
- },
515
+ offset: 1
516
+ }
517
517
  ];
518
518
  const coverFlipOut = [
519
519
  {
520
520
  opacity: 1,
521
521
  transform: 'perspective(800px) rotateY(0deg) translateX(0)',
522
- offset: 0,
522
+ offset: 0
523
523
  },
524
524
  {
525
525
  opacity: 0,
526
526
  transform: 'perspective(800px) rotateY(12deg) translateX(8px)',
527
- offset: 1,
528
- },
527
+ offset: 1
528
+ }
529
529
  ];
530
530
 
531
531
  var defaultTransitions = /*#__PURE__*/Object.freeze({
@@ -607,19 +607,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
607
607
  type: Directive,
608
608
  args: [{
609
609
  standalone: true,
610
- selector: '[noTransition]',
610
+ selector: '[noTransition]'
611
611
  }]
612
612
  }] });
613
613
 
614
614
  /**@internal*/
615
- function hashCode(str) {
616
- let hash = 0;
617
- for (let i = 0, len = str.length; i < len; i++) {
618
- const code = str.charCodeAt(i);
619
- hash = (hash << 5) - hash + code;
620
- hash |= 0; // Convert to 32bit integer
621
- }
622
- return hash;
615
+ function fnv1aHash(str) {
616
+ let hash = 2166136261;
617
+ for (let i = 0; i < str.length; i++) {
618
+ hash ^= str.charCodeAt(i);
619
+ hash = Math.imul(hash, 16777619);
620
+ }
621
+ return hash >>> 0;
623
622
  }
624
623
  /**@internal*/
625
624
  function isValidCustomIdentValue(value) {
@@ -645,7 +644,7 @@ class KeyframesService {
645
644
  }
646
645
  setKeyframes(keyframes) {
647
646
  const keyframesAsString = JSON.stringify(keyframes);
648
- const hashedKeyframes = hashCode(keyframesAsString);
647
+ const hashedKeyframes = fnv1aHash(keyframesAsString);
649
648
  const keyframesName = `keyframes-${hashedKeyframes}`;
650
649
  if (this._insertedKeyframes.has(keyframesName))
651
650
  return keyframesName;
@@ -685,29 +684,23 @@ class ViewTransitionsService {
685
684
  this._renderer = this._rendererFactory.createRenderer(null, null);
686
685
  this._document = inject(DOCUMENT);
687
686
  }
688
- setOutAnimation(outAnimation, transitionName) {
689
- const elementId = `view-transition-out-${transitionName}`;
690
- const styleElement = this._document.getElementById(elementId) || this._document.createElement('style');
691
- styleElement.innerHTML = `
692
- ::view-transition-old(${transitionName}){
693
- animation: ${outAnimation};
694
- }
695
- `;
696
- styleElement.id = elementId;
697
- if (!this._document.getElementById(elementId))
698
- this._renderer.appendChild(this._document.head, styleElement);
699
- }
700
- setInAnimation(inAnimation, transitionName) {
701
- const elementId = `view-transition-in-${transitionName}`;
687
+ setTransition(transitionName, animation, direction) {
688
+ const elementId = `view-transition-${direction}-${transitionName}`;
689
+ if (this._document.getElementById(elementId))
690
+ return;
702
691
  const styleElement = this._document.getElementById(elementId) || this._document.createElement('style');
703
692
  styleElement.innerHTML = `
704
- ::view-transition-new(${transitionName}){
705
- animation: ${inAnimation};
693
+ ::view-transition-${direction === 'in' ? 'new' : 'old'}(${transitionName}){
694
+ animation-name: ${animation.name};
695
+ animation-duration: ${animation.duration}ms;
696
+ animation-delay: ${animation.delay ?? 0}ms;
697
+ animation-direction: ${animation.reverse ? 'reverse' : 'normal'};
698
+ animation-fill-mode: ${animation.fillMode ?? 'none'};
699
+ animation-timing-function: ${animation.timingFunction ?? 'ease'};
706
700
  }
707
701
  `;
708
702
  styleElement.id = elementId;
709
- if (!this._document.getElementById(elementId))
710
- this._renderer.appendChild(this._document.head, styleElement);
703
+ this._renderer.appendChild(this._document.head, styleElement);
711
704
  }
712
705
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: ViewTransitionsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
713
706
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: ViewTransitionsService, providedIn: 'root' }); }
@@ -725,7 +718,7 @@ class TransitionNameDirective {
725
718
  /**
726
719
  * Set the `view-transition-name` property to assign transitions to that element
727
720
  */
728
- this.transitionName = input.required(...(ngDevMode ? [{ debugName: "transitionName" }] : []));
721
+ this.originalTransitionName = input.required({ ...(ngDevMode ? { debugName: "originalTransitionName" } : {}), alias: 'transitionName' });
729
722
  /**
730
723
  * Configure the animation when the element enters the view
731
724
  */
@@ -734,60 +727,86 @@ class TransitionNameDirective {
734
727
  * Configure the animation when the element leaves the view
735
728
  */
736
729
  this.outAnimation = input(...(ngDevMode ? [undefined, { debugName: "outAnimation" }] : []));
730
+ /**
731
+ * Whether to keep the original transition name or apply hashing for CSS safety.
732
+ * Defaults to `false`. Set to `true` to use the name as provided without hashing.
733
+ */
734
+ this.preserveName = input(false, ...(ngDevMode ? [{ debugName: "preserveName" }] : []));
735
+ /**
736
+ * Whether to show the `data-original-view-transition-name` containing the provided transition name. Useful for debugging when hashing is enabled. Defaults to `false`.
737
+ */
738
+ this.showOriginalNameAttr = input(false, ...(ngDevMode ? [{ debugName: "showOriginalNameAttr" }] : []));
737
739
  this._el = inject(ElementRef);
738
740
  this._renderer = inject(Renderer2);
739
741
  this._keyframesService = inject(KeyframesService);
740
742
  this._viewTransitionsService = inject(ViewTransitionsService);
743
+ this._transitionName = computed(() => {
744
+ const originalTransitionName = this.originalTransitionName();
745
+ return this.preserveName() ? originalTransitionName : `vtn-${fnv1aHash(originalTransitionName)}`;
746
+ }, ...(ngDevMode ? [{ debugName: "_transitionName" }] : []));
741
747
  //transitionName
742
748
  effect(() => {
743
- const transitionName = this.transitionName();
744
- this._renderer.setStyle(this._el.nativeElement, 'view-transition-name', transitionName);
749
+ this._renderer.setStyle(this._el.nativeElement, 'view-transition-name', this._transitionName());
750
+ });
751
+ //originalNameAttr
752
+ effect(() => {
745
753
  queueMicrotask(() => {
746
- if (!isValidViewTransitionName(transitionName))
747
- console.warn(`The transition name "${transitionName}" is potentially invalid. Please use a valid CSS <custom-ident> value and avoid forbidden values like "unset", "initial", "inherit" and "none".`);
754
+ if (this.showOriginalNameAttr()) {
755
+ this._renderer.setAttribute(this._el.nativeElement, 'data-original-view-transition-name', untracked(this.originalTransitionName));
756
+ }
757
+ });
758
+ });
759
+ //warn if invalid transition name
760
+ effect(() => {
761
+ queueMicrotask(() => {
762
+ if (!this.preserveName())
763
+ return;
764
+ const transitionName = this._transitionName();
765
+ if (isValidViewTransitionName(transitionName))
766
+ return;
767
+ console.warn(`The provided transition name "${transitionName}" is potentially invalid. Please use a valid CSS <custom-ident> value and avoid forbidden values like "unset", "initial", "inherit" and "none". Or use hashing by setting "preserveName" to false.`);
748
768
  });
749
769
  });
750
770
  //inAnimation
751
771
  effect(async () => {
752
- const inAnimation = this.inAnimation();
753
- if (!inAnimation)
772
+ const animation = this.inAnimation();
773
+ if (!animation)
754
774
  return;
755
- if ('keyframesName' in inAnimation) {
756
- const animation = inAnimation;
757
- this._viewTransitionsService.setInAnimation(`${animation.duration}ms ${animation.keyframesName} ${animation.reverse ? 'reverse' : ''}`, this.transitionName());
758
- }
759
- if ('keyframes' in inAnimation) {
760
- const animation = inAnimation;
761
- const keyframesName = this._keyframesService.setKeyframes(animation.keyframes);
762
- this._viewTransitionsService.setInAnimation(`${animation.duration}ms ${keyframesName} ${animation.reverse ? 'reverse' : ''}`, this.transitionName());
763
- }
775
+ this.setTransition(this._transitionName(), animation, 'in');
764
776
  });
765
777
  //outAnimation
766
778
  effect(async () => {
767
- const outAnimation = this.outAnimation();
768
- if (!outAnimation)
779
+ const animation = this.outAnimation();
780
+ if (!animation)
769
781
  return;
770
- if ('keyframesName' in outAnimation) {
771
- const animation = outAnimation;
772
- this._viewTransitionsService.setOutAnimation(`${animation.duration}ms ${animation.keyframesName} ${animation.reverse ? 'reverse' : ''}`, this.transitionName());
773
- }
774
- if ('keyframes' in outAnimation) {
775
- const animation = outAnimation;
776
- const keyframesName = this._keyframesService.setKeyframes(animation.keyframes);
777
- this._viewTransitionsService.setOutAnimation(`${animation.duration}ms ${keyframesName} ${animation.reverse ? 'reverse' : ''}`, this.transitionName());
778
- }
782
+ this.setTransition(this._transitionName(), animation, 'out');
779
783
  });
780
784
  }
785
+ setTransition(transitionName, transition, direction) {
786
+ let animationName = null;
787
+ if ('keyframesName' in transition) {
788
+ animationName = transition.keyframesName;
789
+ }
790
+ if ('keyframes' in transition) {
791
+ animationName = this._keyframesService.setKeyframes(transition.keyframes);
792
+ }
793
+ if (!animationName)
794
+ return;
795
+ this._viewTransitionsService.setTransition(transitionName, {
796
+ name: animationName,
797
+ ...transition
798
+ }, direction);
799
+ }
781
800
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TransitionNameDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
782
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: TransitionNameDirective, isStandalone: true, selector: "[transitionName]", inputs: { transitionName: { classPropertyName: "transitionName", publicName: "transitionName", isSignal: true, isRequired: true, transformFunction: null }, inAnimation: { classPropertyName: "inAnimation", publicName: "inAnimation", isSignal: true, isRequired: false, transformFunction: null }, outAnimation: { classPropertyName: "outAnimation", publicName: "outAnimation", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
801
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.1.1", type: TransitionNameDirective, isStandalone: true, selector: "[transitionName]", inputs: { originalTransitionName: { classPropertyName: "originalTransitionName", publicName: "transitionName", isSignal: true, isRequired: true, transformFunction: null }, inAnimation: { classPropertyName: "inAnimation", publicName: "inAnimation", isSignal: true, isRequired: false, transformFunction: null }, outAnimation: { classPropertyName: "outAnimation", publicName: "outAnimation", isSignal: true, isRequired: false, transformFunction: null }, preserveName: { classPropertyName: "preserveName", publicName: "preserveName", isSignal: true, isRequired: false, transformFunction: null }, showOriginalNameAttr: { classPropertyName: "showOriginalNameAttr", publicName: "showOriginalNameAttr", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
783
802
  }
784
803
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImport: i0, type: TransitionNameDirective, decorators: [{
785
804
  type: Directive,
786
805
  args: [{
787
806
  standalone: true,
788
- selector: '[transitionName]',
807
+ selector: '[transitionName]'
789
808
  }]
790
- }], ctorParameters: () => [], propDecorators: { transitionName: [{ type: i0.Input, args: [{ isSignal: true, alias: "transitionName", required: true }] }], inAnimation: [{ type: i0.Input, args: [{ isSignal: true, alias: "inAnimation", required: false }] }], outAnimation: [{ type: i0.Input, args: [{ isSignal: true, alias: "outAnimation", required: false }] }] } });
809
+ }], ctorParameters: () => [], propDecorators: { originalTransitionName: [{ type: i0.Input, args: [{ isSignal: true, alias: "transitionName", required: true }] }], inAnimation: [{ type: i0.Input, args: [{ isSignal: true, alias: "inAnimation", required: false }] }], outAnimation: [{ type: i0.Input, args: [{ isSignal: true, alias: "outAnimation", required: false }] }], preserveName: [{ type: i0.Input, args: [{ isSignal: true, alias: "preserveName", required: false }] }], showOriginalNameAttr: [{ type: i0.Input, args: [{ isSignal: true, alias: "showOriginalNameAttr", required: false }] }] } });
791
810
 
792
811
  /**
793
812
  * Override the default View Transition API cross-fade animation
@@ -795,25 +814,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
795
814
  * @param outAnimation
796
815
  */
797
816
  function provideDefaultViewTransition(inAnimation, outAnimation) {
798
- const factory = (viewTransitionService, keyframesService) => {
799
- return () => {
800
- if ('keyframesName' in inAnimation) {
801
- const animation = inAnimation;
802
- viewTransitionService.setInAnimation(`${animation.duration}ms ${animation.keyframesName} ${animation.reverse ? 'reverse' : ''}`, 'root');
817
+ const factory = (viewTransitionsService, keyframesService) => {
818
+ const setTransition = (transitionName, transition, direction) => {
819
+ let animationName = null;
820
+ if ('keyframesName' in transition) {
821
+ animationName = transition.keyframesName;
803
822
  }
804
- if ('keyframes' in inAnimation) {
805
- const animation = inAnimation;
806
- const keyframesName = keyframesService.setKeyframes(animation.keyframes);
807
- viewTransitionService.setInAnimation(`${animation.duration}ms ${keyframesName} ${animation.reverse ? 'reverse' : ''}`, 'root');
823
+ if ('keyframes' in transition) {
824
+ animationName = keyframesService.setKeyframes(transition.keyframes);
808
825
  }
809
- if ('keyframesName' in outAnimation) {
810
- const animation = outAnimation;
811
- viewTransitionService.setOutAnimation(`${animation.duration}ms ${animation.keyframesName} ${animation.reverse ? 'reverse' : ''}`, 'root');
826
+ if (!animationName)
827
+ return;
828
+ viewTransitionsService.setTransition(transitionName, {
829
+ name: animationName,
830
+ ...transition
831
+ }, direction);
832
+ };
833
+ return () => {
834
+ if (inAnimation) {
835
+ setTransition('root', inAnimation, 'in');
812
836
  }
813
- if ('keyframes' in outAnimation) {
814
- const animation = outAnimation;
815
- const keyframesName = keyframesService.setKeyframes(animation.keyframes);
816
- viewTransitionService.setOutAnimation(`${animation.duration}ms ${keyframesName} ${animation.reverse ? 'reverse' : ''}`, 'root');
837
+ if (outAnimation) {
838
+ setTransition('root', outAnimation, 'out');
817
839
  }
818
840
  };
819
841
  };