@angular-wave/angular.ts 0.0.56 → 0.0.57
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/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +1 -1
- package/src/animations/animate-css.html +6 -2
- package/src/animations/animate-css.js +0 -1
- package/src/core/animate/animate.js +97 -195
- package/src/directive/if/if.js +24 -10
- package/src/directive/if/if.md +2 -2
- package/src/shared/utils.js +23 -0
- package/types/core/animate/animate.d.ts +93 -172
- package/types/directive/if/if.d.ts +6 -3
- package/types/shared/utils.d.ts +6 -0
package/package.json
CHANGED
|
@@ -19,9 +19,13 @@
|
|
|
19
19
|
</script>
|
|
20
20
|
|
|
21
21
|
<style>
|
|
22
|
+
.fade {
|
|
23
|
+
background-color: red;
|
|
24
|
+
}
|
|
22
25
|
/* The starting CSS styles for the enter animation */
|
|
23
26
|
.fade.ng-enter {
|
|
24
27
|
transition: 0.5s linear all;
|
|
28
|
+
background-color: white;
|
|
25
29
|
opacity: 0;
|
|
26
30
|
}
|
|
27
31
|
|
|
@@ -34,18 +38,18 @@
|
|
|
34
38
|
/* The starting CSS styles for the leave animation */
|
|
35
39
|
.fade.ng-leave {
|
|
36
40
|
transition: 0.5s linear all;
|
|
37
|
-
background-color: blue;
|
|
38
41
|
opacity: 1;
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
/* The finishing CSS styles for the leave animation */
|
|
42
45
|
.fade.ng-leave.ng-leave-active {
|
|
43
46
|
opacity: 0;
|
|
47
|
+
background-color: white;
|
|
44
48
|
}
|
|
45
49
|
</style>
|
|
46
50
|
</head>
|
|
47
51
|
<body ng-app="test">
|
|
48
|
-
<div ng-if="bool" class="fade">Fade me in out</div>
|
|
52
|
+
<div ng-if="bool" class="fade" data-animate="true">Fade me in out</div>
|
|
49
53
|
<button ng-click="bool=true">Fade In!</button>
|
|
50
54
|
<button ng-click="bool=false">Fade Out!</button>
|
|
51
55
|
</body>
|
|
@@ -10,6 +10,16 @@ import { JQLite } from "../../shared/jqlite/jqlite";
|
|
|
10
10
|
import { NG_ANIMATE_CLASSNAME } from "../../animations/shared";
|
|
11
11
|
import { addInlineStyles } from "./helpers";
|
|
12
12
|
|
|
13
|
+
/** @typedef {"enter"|"leave"|"move"|"addClass"|"setClass"|"removeClass"} AnimationMethod */
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {Object} AnimationOptions
|
|
17
|
+
* @property {string} addClass - space-separated CSS classes to add to element
|
|
18
|
+
* @property {Object} from - CSS properties & values at the beginning of animation. Must have matching `to`
|
|
19
|
+
* @property {string} removeClass - space-separated CSS classes to remove from element
|
|
20
|
+
* @property {string} to - CSS properties & values at end of animation. Must have matching `from`
|
|
21
|
+
*/
|
|
22
|
+
|
|
13
23
|
const $animateMinErr = minErr("$animate");
|
|
14
24
|
|
|
15
25
|
function mergeClasses(a, b) {
|
|
@@ -60,10 +70,6 @@ function prepareAnimateOptions(options) {
|
|
|
60
70
|
return isObject(options) ? options : {};
|
|
61
71
|
}
|
|
62
72
|
|
|
63
|
-
export function CoreAnimateJsProvider() {
|
|
64
|
-
this.$get = () => {};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
73
|
// this is prefixed with Core since it conflicts with
|
|
68
74
|
// the animateQueueProvider defined in ngAnimate/animateQueue.js
|
|
69
75
|
export function CoreAnimateQueueProvider() {
|
|
@@ -179,6 +185,27 @@ export function CoreAnimateQueueProvider() {
|
|
|
179
185
|
];
|
|
180
186
|
}
|
|
181
187
|
|
|
188
|
+
export function domInsert(element, parentElement, afterElement) {
|
|
189
|
+
// if for some reason the previous element was removed
|
|
190
|
+
// from the dom sometime before this code runs then let's
|
|
191
|
+
// just stick to using the parent element as the anchor
|
|
192
|
+
if (afterElement) {
|
|
193
|
+
const afterNode = extractElementNode(afterElement);
|
|
194
|
+
if (
|
|
195
|
+
afterNode &&
|
|
196
|
+
!afterNode.parentNode &&
|
|
197
|
+
!afterNode.previousElementSibling
|
|
198
|
+
) {
|
|
199
|
+
afterElement = null;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (afterElement) {
|
|
203
|
+
afterElement.after(element);
|
|
204
|
+
} else {
|
|
205
|
+
parentElement.prepend(element);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
182
209
|
AnimateProvider.$inject = ["$provide"];
|
|
183
210
|
export function AnimateProvider($provide) {
|
|
184
211
|
const provider = this;
|
|
@@ -327,31 +354,8 @@ export function AnimateProvider($provide) {
|
|
|
327
354
|
this.$get = [
|
|
328
355
|
"$$animateQueue",
|
|
329
356
|
function ($$animateQueue) {
|
|
330
|
-
function domInsert(element, parentElement, afterElement) {
|
|
331
|
-
// if for some reason the previous element was removed
|
|
332
|
-
// from the dom sometime before this code runs then let's
|
|
333
|
-
// just stick to using the parent element as the anchor
|
|
334
|
-
if (afterElement) {
|
|
335
|
-
const afterNode = extractElementNode(afterElement);
|
|
336
|
-
if (
|
|
337
|
-
afterNode &&
|
|
338
|
-
!afterNode.parentNode &&
|
|
339
|
-
!afterNode.previousElementSibling
|
|
340
|
-
) {
|
|
341
|
-
afterElement = null;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
if (afterElement) {
|
|
345
|
-
afterElement.after(element);
|
|
346
|
-
} else {
|
|
347
|
-
parentElement.prepend(element);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
|
|
351
357
|
/**
|
|
352
|
-
*
|
|
353
|
-
* @name $animate
|
|
354
|
-
* @description The $animate service exposes a series of DOM utility methods that provide support
|
|
358
|
+
* The $animate service exposes a series of DOM utility methods that provide support
|
|
355
359
|
* for animation hooks. The default behavior is the application of DOM operations, however,
|
|
356
360
|
* when an animation is detected (and animations are enabled), $animate will do the heavy lifting
|
|
357
361
|
* to ensure that animation runs with the triggered DOM operation.
|
|
@@ -363,20 +367,11 @@ export function AnimateProvider($provide) {
|
|
|
363
367
|
* `ngShow`, `ngHide` and `ngMessages` also provide support for animations.
|
|
364
368
|
*
|
|
365
369
|
* It is recommended that the`$animate` service is always used when executing DOM-related procedures within directives.
|
|
366
|
-
*
|
|
367
|
-
* To learn more about enabling animation support, click here to visit the
|
|
368
|
-
* {@link ngAnimate ngAnimate module page}.
|
|
369
370
|
*/
|
|
370
371
|
return {
|
|
371
|
-
// we don't call it directly since non-existant arguments may
|
|
372
|
-
// be interpreted as null within the sub enabled function
|
|
373
|
-
|
|
374
372
|
/**
|
|
375
373
|
*
|
|
376
|
-
*
|
|
377
|
-
* @name $animate#on
|
|
378
|
-
* @kind function
|
|
379
|
-
* @description Sets up an event listener to fire whenever the animation event (enter, leave, move, etc...)
|
|
374
|
+
* Sets up an event listener to fire whenever the animation event (enter, leave, move, etc...)
|
|
380
375
|
* has fired on the given element or among any of its children. Once the listener is fired, the provided callback
|
|
381
376
|
* is fired with the following params:
|
|
382
377
|
*
|
|
@@ -425,11 +420,7 @@ export function AnimateProvider($provide) {
|
|
|
425
420
|
on: $$animateQueue.on,
|
|
426
421
|
|
|
427
422
|
/**
|
|
428
|
-
*
|
|
429
|
-
* @ngdoc method
|
|
430
|
-
* @name $animate#off
|
|
431
|
-
* @kind function
|
|
432
|
-
* @description Deregisters an event listener based on the event which has been associated with the provided element. This method
|
|
423
|
+
* Deregisters an event listener based on the event which has been associated with the provided element. This method
|
|
433
424
|
* can be used in three different ways depending on the arguments:
|
|
434
425
|
*
|
|
435
426
|
* ```js
|
|
@@ -456,17 +447,14 @@ export function AnimateProvider($provide) {
|
|
|
456
447
|
off: $$animateQueue.off,
|
|
457
448
|
|
|
458
449
|
/**
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
*
|
|
465
|
-
* was bootstrapped on an element that is somewhere inside of the `<body>` tag, but we wanted to allow for an element to be situated
|
|
466
|
-
* as a direct child of `document.body`, then this can be achieved by pinning the element via `$animate.pin(element)`. Keep in mind
|
|
467
|
-
* that calling `$animate.pin(element, parentElement)` will not actually insert into the DOM anywhere; it will just create the association.
|
|
450
|
+
* Associates the provided element with a host parent element to allow the element to be animated even if it exists
|
|
451
|
+
* outside of the DOM structure of the AngularJS application. By doing so, any animation triggered via `$animate` can be issued on the
|
|
452
|
+
* element despite being outside the realm of the application or within another application. Say for example if the application
|
|
453
|
+
* was bootstrapped on an element that is somewhere inside of the `<body>` tag, but we wanted to allow for an element to be situated
|
|
454
|
+
* as a direct child of `document.body`, then this can be achieved by pinning the element via `$animate.pin(element)`. Keep in mind
|
|
455
|
+
* that calling `$animate.pin(element, parentElement)` will not actually insert into the DOM anywhere; it will just create the association.
|
|
468
456
|
*
|
|
469
|
-
*
|
|
457
|
+
* Note that this feature is only active when the `ngAnimate` module is used.
|
|
470
458
|
*
|
|
471
459
|
* @param {Element} element the external element that will be pinned
|
|
472
460
|
* @param {Element} parentElement the host parent element that will be associated with the external element
|
|
@@ -505,14 +493,11 @@ export function AnimateProvider($provide) {
|
|
|
505
493
|
enabled: $$animateQueue.enabled,
|
|
506
494
|
|
|
507
495
|
/**
|
|
508
|
-
*
|
|
509
|
-
* @name $animate#cancel
|
|
510
|
-
* @kind function
|
|
511
|
-
* @description Cancels the provided animation and applies the end state of the animation.
|
|
496
|
+
* Cancels the provided animation and applies the end state of the animation.
|
|
512
497
|
* Note that this does not cancel the underlying operation, e.g. the setting of classes or
|
|
513
498
|
* adding the element to the DOM.
|
|
514
499
|
*
|
|
515
|
-
* @param {
|
|
500
|
+
* @param {import('./animate-runner').AnimateRunner} runner An animation runner returned by an $animate function.
|
|
516
501
|
*
|
|
517
502
|
* @example
|
|
518
503
|
<example module="animationExample" deps="angular-animate.js" animations="true" name="animate-cancel">
|
|
@@ -583,28 +568,16 @@ export function AnimateProvider($provide) {
|
|
|
583
568
|
},
|
|
584
569
|
|
|
585
570
|
/**
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
*
|
|
593
|
-
*
|
|
594
|
-
*
|
|
595
|
-
* @
|
|
596
|
-
* @param {Element} parent the parent element which will append the element as
|
|
597
|
-
* a child (so long as the after element is not present)
|
|
598
|
-
* @param {Element=} after the sibling element after which the element will be appended
|
|
599
|
-
* @param {object=} options an optional collection of options/styles that will be applied to the element.
|
|
600
|
-
* The object can have the following properties:
|
|
601
|
-
*
|
|
602
|
-
* - **addClass** - `{string}` - space-separated CSS classes to add to element
|
|
603
|
-
* - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
|
|
604
|
-
* - **removeClass** - `{string}` - space-separated CSS classes to remove from element
|
|
605
|
-
* - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
|
|
606
|
-
*
|
|
607
|
-
* @return {Runner} the animation runner
|
|
571
|
+
* Inserts the element into the DOM either after the `after` element (if provided) or
|
|
572
|
+
* as the first child within the `parent` element and then triggers an animation.
|
|
573
|
+
* A promise is returned that will be resolved during the next digest once the animation
|
|
574
|
+
* has completed.
|
|
575
|
+
*
|
|
576
|
+
* @param {JQLite} element - the element which will be inserted into the DOM
|
|
577
|
+
* @param {JQLite} parent - the parent element which will append the element as a child (so long as the after element is not present)
|
|
578
|
+
* @param {JQLite} after - after the sibling element after which the element will be appended
|
|
579
|
+
* @param {AnimationOptions} [options] - an optional collection of options/styles that will be applied to the element.
|
|
580
|
+
* @returns {import('./animate-runner').AnimateRunner} the animation runner
|
|
608
581
|
*/
|
|
609
582
|
enter(element, parent, after, options) {
|
|
610
583
|
parent = parent && JQLite(parent);
|
|
@@ -619,28 +592,16 @@ export function AnimateProvider($provide) {
|
|
|
619
592
|
},
|
|
620
593
|
|
|
621
594
|
/**
|
|
622
|
-
*
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
* @
|
|
632
|
-
* @param {Element} parent the parent element which will append the element as
|
|
633
|
-
* a child (so long as the after element is not present)
|
|
634
|
-
* @param {Element=} after the sibling element after which the element will be appended
|
|
635
|
-
* @param {object=} options an optional collection of options/styles that will be applied to the element.
|
|
636
|
-
* The object can have the following properties:
|
|
637
|
-
*
|
|
638
|
-
* - **addClass** - `{string}` - space-separated CSS classes to add to element
|
|
639
|
-
* - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
|
|
640
|
-
* - **removeClass** - `{string}` - space-separated CSS classes to remove from element
|
|
641
|
-
* - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
|
|
642
|
-
*
|
|
643
|
-
* @return {Runner} the animation runner
|
|
595
|
+
* Inserts (moves) the element into its new position in the DOM either after
|
|
596
|
+
* the `after` element (if provided) or as the first child within the `parent` element
|
|
597
|
+
* and then triggers an animation. A promise is returned that will be resolved
|
|
598
|
+
* during the next digest once the animation has completed.
|
|
599
|
+
*
|
|
600
|
+
* @param {JQLite} element - the element which will be inserted into the DOM
|
|
601
|
+
* @param {JQLite} parent - the parent element which will append the element as a child (so long as the after element is not present)
|
|
602
|
+
* @param {JQLite} after - after the sibling element after which the element will be appended
|
|
603
|
+
* @param {AnimationOptions} [options] - an optional collection of options/styles that will be applied to the element.
|
|
604
|
+
* @returns {import('./animate-runner').AnimateRunner} the animation runner
|
|
644
605
|
*/
|
|
645
606
|
move(element, parent, after, options) {
|
|
646
607
|
parent = parent && JQLite(parent);
|
|
@@ -655,23 +616,13 @@ export function AnimateProvider($provide) {
|
|
|
655
616
|
},
|
|
656
617
|
|
|
657
618
|
/**
|
|
658
|
-
*
|
|
659
|
-
* @name $animate#leave
|
|
660
|
-
* @kind function
|
|
661
|
-
* @description Triggers an animation and then removes the element from the DOM.
|
|
619
|
+
* Triggers an animation and then removes the element from the DOM.
|
|
662
620
|
* When the function is called a promise is returned that will be resolved during the next
|
|
663
621
|
* digest once the animation has completed.
|
|
664
622
|
*
|
|
665
|
-
* @param {
|
|
666
|
-
* @param {
|
|
667
|
-
*
|
|
668
|
-
*
|
|
669
|
-
* - **addClass** - `{string}` - space-separated CSS classes to add to element
|
|
670
|
-
* - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
|
|
671
|
-
* - **removeClass** - `{string}` - space-separated CSS classes to remove from element
|
|
672
|
-
* - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
|
|
673
|
-
*
|
|
674
|
-
* @return {Runner} the animation runner
|
|
623
|
+
* @param {JQLite} element the element which will be removed from the DOM
|
|
624
|
+
* @param {AnimationOptions} [options] an optional collection of options/styles that will be applied to the element.
|
|
625
|
+
* @returns {import('./animate-runner').AnimateRunner} the animation runner
|
|
675
626
|
*/
|
|
676
627
|
leave(element, options) {
|
|
677
628
|
return $$animateQueue.push(
|
|
@@ -685,56 +636,36 @@ export function AnimateProvider($provide) {
|
|
|
685
636
|
},
|
|
686
637
|
|
|
687
638
|
/**
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
*
|
|
691
|
-
*
|
|
692
|
-
*
|
|
693
|
-
*
|
|
694
|
-
*
|
|
695
|
-
*
|
|
696
|
-
* (like enter, move and leave) since the CSS classes may be added/removed at different points
|
|
697
|
-
* depending if CSS or JavaScript animations are used.
|
|
698
|
-
*
|
|
699
|
-
* @param {Element} element the element which the CSS classes will be applied to
|
|
639
|
+
* Triggers an addClass animation surrounding the addition of the provided CSS class(es). Upon
|
|
640
|
+
* execution, the addClass operation will only be handled after the next digest and it will not trigger an
|
|
641
|
+
* animation if element already contains the CSS class or if the class is removed at a later step.
|
|
642
|
+
* Note that class-based animations are treated differently compared to structural animations
|
|
643
|
+
* (like enter, move and leave) since the CSS classes may be added/removed at different points
|
|
644
|
+
* depending if CSS or JavaScript animations are used.
|
|
645
|
+
*
|
|
646
|
+
* @param {JQLite} element the element which the CSS classes will be applied to
|
|
700
647
|
* @param {string} className the CSS class(es) that will be added (multiple classes are separated via spaces)
|
|
701
|
-
* @param {
|
|
702
|
-
*
|
|
703
|
-
*
|
|
704
|
-
* - **removeClass** - `{string}` - space-separated CSS classes to remove from element
|
|
705
|
-
* - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
|
|
706
|
-
* - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
|
|
707
|
-
*
|
|
708
|
-
* @return {Runner} animationRunner the animation runner
|
|
648
|
+
* @param {AnimationOptions} [options] an optional collection of options/styles that will be applied to the element.
|
|
649
|
+
* @return {import('./animate-runner').AnimateRunner}} animationRunner the animation runner
|
|
709
650
|
*/
|
|
710
651
|
addClass(element, className, options) {
|
|
711
652
|
options = prepareAnimateOptions(options);
|
|
712
|
-
options.addClass = mergeClasses(options.
|
|
653
|
+
options.addClass = mergeClasses(options.addClass, className);
|
|
713
654
|
return $$animateQueue.push(element, "addClass", options);
|
|
714
655
|
},
|
|
715
656
|
|
|
716
657
|
/**
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
*
|
|
720
|
-
*
|
|
721
|
-
*
|
|
722
|
-
*
|
|
723
|
-
*
|
|
724
|
-
*
|
|
725
|
-
* (like enter, move and leave) since the CSS classes may be added/removed at different points
|
|
726
|
-
* depending if CSS or JavaScript animations are used.
|
|
727
|
-
*
|
|
728
|
-
* @param {Element} element the element which the CSS classes will be applied to
|
|
658
|
+
* Triggers a removeClass animation surrounding the removal of the provided CSS class(es). Upon
|
|
659
|
+
* execution, the removeClass operation will only be handled after the next digest and it will not trigger an
|
|
660
|
+
* animation if element does not contain the CSS class or if the class is added at a later step.
|
|
661
|
+
* Note that class-based animations are treated differently compared to structural animations
|
|
662
|
+
* (like enter, move and leave) since the CSS classes may be added/removed at different points
|
|
663
|
+
* depending if CSS or JavaScript animations are used.
|
|
664
|
+
*
|
|
665
|
+
* @param {JQLite} element the element which the CSS classes will be applied to
|
|
729
666
|
* @param {string} className the CSS class(es) that will be removed (multiple classes are separated via spaces)
|
|
730
|
-
* @param {
|
|
731
|
-
*
|
|
732
|
-
*
|
|
733
|
-
* - **addClass** - `{string}` - space-separated CSS classes to add to element
|
|
734
|
-
* - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
|
|
735
|
-
* - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
|
|
736
|
-
*
|
|
737
|
-
* @return {Runner} the animation runner
|
|
667
|
+
* @param {AnimationOptions} [options] an optional collection of options/styles that will be applied to the element. *
|
|
668
|
+
* @return {import('./animate-runner').AnimateRunner} animationRunner the animation runner
|
|
738
669
|
*/
|
|
739
670
|
removeClass(element, className, options) {
|
|
740
671
|
options = prepareAnimateOptions(options);
|
|
@@ -743,29 +674,19 @@ export function AnimateProvider($provide) {
|
|
|
743
674
|
},
|
|
744
675
|
|
|
745
676
|
/**
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
751
|
-
*
|
|
752
|
-
* `$animate.removeClass`, `setClass` will only evaluate the classes being added/removed once a digest has
|
|
753
|
-
* passed. Note that class-based animations are treated differently compared to structural animations
|
|
754
|
-
* (like enter, move and leave) since the CSS classes may be added/removed at different points
|
|
755
|
-
* depending if CSS or JavaScript animations are used.
|
|
677
|
+
* Performs both the addition and removal of a CSS classes on an element and (during the process)
|
|
678
|
+
* triggers an animation surrounding the class addition/removal. Much like `$animate.addClass` and
|
|
679
|
+
* `$animate.removeClass`, `setClass` will only evaluate the classes being added/removed once a digest has
|
|
680
|
+
* passed. Note that class-based animations are treated differently compared to structural animations
|
|
681
|
+
* (like enter, move and leave) since the CSS classes may be added/removed at different points
|
|
682
|
+
* depending if CSS or JavaScript animations are used.
|
|
756
683
|
*
|
|
757
684
|
* @param {Element} element the element which the CSS classes will be applied to
|
|
758
685
|
* @param {string} add the CSS class(es) that will be added (multiple classes are separated via spaces)
|
|
759
686
|
* @param {string} remove the CSS class(es) that will be removed (multiple classes are separated via spaces)
|
|
760
687
|
* @param {object=} options an optional collection of options/styles that will be applied to the element.
|
|
761
|
-
* The object can have the following properties:
|
|
762
688
|
*
|
|
763
|
-
*
|
|
764
|
-
* - **removeClass** - `{string}` - space-separated CSS classes to remove from element
|
|
765
|
-
* - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
|
|
766
|
-
* - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
|
|
767
|
-
*
|
|
768
|
-
* @return {Runner} the animation runner
|
|
689
|
+
* @return {import('./animate-runner').AnimateRunner} the animation runner
|
|
769
690
|
*/
|
|
770
691
|
setClass(element, add, remove, options) {
|
|
771
692
|
options = prepareAnimateOptions(options);
|
|
@@ -775,11 +696,7 @@ export function AnimateProvider($provide) {
|
|
|
775
696
|
},
|
|
776
697
|
|
|
777
698
|
/**
|
|
778
|
-
*
|
|
779
|
-
* @name $animate#animate
|
|
780
|
-
* @kind function
|
|
781
|
-
*
|
|
782
|
-
* @description Performs an inline animation on the element which applies the provided to and from CSS styles to the element.
|
|
699
|
+
* Performs an inline animation on the element which applies the provided to and from CSS styles to the element.
|
|
783
700
|
* If any detected CSS transition, keyframe or JavaScript matches the provided className value, then the animation will take
|
|
784
701
|
* on the provided styles. For example, if a transition animation is set for the given className, then the provided `from` and
|
|
785
702
|
* `to` styles will be applied alongside the given transition. If the CSS style provided in `from` does not have a corresponding
|
|
@@ -797,22 +714,7 @@ export function AnimateProvider($provide) {
|
|
|
797
714
|
* }
|
|
798
715
|
* });
|
|
799
716
|
* ```
|
|
800
|
-
*
|
|
801
|
-
* @param {Element} element the element which the CSS styles will be applied to
|
|
802
|
-
* @param {object} from the from (starting) CSS styles that will be applied to the element and across the animation.
|
|
803
|
-
* @param {object} to the to (destination) CSS styles that will be applied to the element and across the animation.
|
|
804
|
-
* @param {string=} className an optional CSS class that will be applied to the element for the duration of the animation. If
|
|
805
|
-
* this value is left as empty then a CSS class of `ng-inline-animate` will be applied to the element.
|
|
806
|
-
* (Note that if no animation is detected then this value will not be applied to the element.)
|
|
807
|
-
* @param {object=} options an optional collection of options/styles that will be applied to the element.
|
|
808
|
-
* The object can have the following properties:
|
|
809
|
-
*
|
|
810
|
-
* - **addClass** - `{string}` - space-separated CSS classes to add to element
|
|
811
|
-
* - **from** - `{Object}` - CSS properties & values at the beginning of animation. Must have matching `to`
|
|
812
|
-
* - **removeClass** - `{string}` - space-separated CSS classes to remove from element
|
|
813
|
-
* - **to** - `{Object}` - CSS properties & values at end of animation. Must have matching `from`
|
|
814
|
-
*
|
|
815
|
-
* @return {Runner} the animation runner
|
|
717
|
+
* @return {import('./animate-runner').AnimateRunner} the animation runner
|
|
816
718
|
*/
|
|
817
719
|
animate(element, from, to, className, options) {
|
|
818
720
|
options = prepareAnimateOptions(options);
|
package/src/directive/if/if.js
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
+
import { domInsert } from "../../core/animate/animate";
|
|
1
2
|
import { getBlockNodes } from "../../shared/jqlite/jqlite";
|
|
3
|
+
import { hasAnimate } from "../../shared/utils";
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
ngIfDirective.$inject = ["$animate"];
|
|
6
|
+
export function ngIfDirective($animate) {
|
|
7
|
+
return {
|
|
6
8
|
multiElement: true,
|
|
7
9
|
transclude: "element",
|
|
8
10
|
priority: 600,
|
|
9
11
|
terminal: true,
|
|
10
12
|
restrict: "A",
|
|
11
|
-
link($scope, $element, $attr,
|
|
13
|
+
link($scope, $element, $attr, _ctrl, $transclude) {
|
|
14
|
+
/** @type {{clone: import("../../shared/jqlite/jqlite").JQLite }} */
|
|
12
15
|
let block;
|
|
16
|
+
|
|
17
|
+
/** @type {import('../../core/scope/scope').Scope} */
|
|
13
18
|
let childScope;
|
|
19
|
+
/** @type {import("../../shared/jqlite/jqlite").JQLite} */
|
|
14
20
|
let previousElements;
|
|
15
21
|
$scope.$watch($attr.ngIf, (value) => {
|
|
16
22
|
if (value) {
|
|
@@ -25,7 +31,11 @@ export const ngIfDirective = [
|
|
|
25
31
|
block = {
|
|
26
32
|
clone,
|
|
27
33
|
};
|
|
28
|
-
|
|
34
|
+
if (hasAnimate(clone[0])) {
|
|
35
|
+
$animate.enter(clone, $element.parent(), $element);
|
|
36
|
+
} else {
|
|
37
|
+
domInsert(clone, $element.parent(), $element);
|
|
38
|
+
}
|
|
29
39
|
});
|
|
30
40
|
}
|
|
31
41
|
} else {
|
|
@@ -39,13 +49,17 @@ export const ngIfDirective = [
|
|
|
39
49
|
}
|
|
40
50
|
if (block) {
|
|
41
51
|
previousElements = getBlockNodes(block.clone);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
if (hasAnimate(previousElements[0])) {
|
|
53
|
+
$animate.leave(previousElements).done((response) => {
|
|
54
|
+
if (response !== false) previousElements = null;
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
previousElements.remove();
|
|
58
|
+
}
|
|
45
59
|
block = null;
|
|
46
60
|
}
|
|
47
61
|
}
|
|
48
62
|
});
|
|
49
63
|
},
|
|
50
|
-
}
|
|
51
|
-
|
|
64
|
+
};
|
|
65
|
+
}
|
package/src/directive/if/if.md
CHANGED
|
@@ -26,8 +26,8 @@ is if an element's class attribute is directly modified after it's compiled, usi
|
|
|
26
26
|
jQuery's `.addClass()` method, and the element is later removed. When `ngIf` recreates the element
|
|
27
27
|
the added class will be lost because the original compiled state is used to regenerate the element.
|
|
28
28
|
|
|
29
|
-
Additionally,
|
|
30
|
-
|
|
29
|
+
Additionally, the `enter` and `leave` animation effects can be enabled for the element by
|
|
30
|
+
setting data attribute (`data-*`) or custom attribute `animate` to `true` attribute.
|
|
31
31
|
|
|
32
32
|
@animations
|
|
33
33
|
| Animation | Occurs |
|
package/src/shared/utils.js
CHANGED
|
@@ -1255,3 +1255,26 @@ export function directiveNormalize(name) {
|
|
|
1255
1255
|
offset ? letter.toUpperCase() : letter,
|
|
1256
1256
|
);
|
|
1257
1257
|
}
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* Whether element should be animated
|
|
1261
|
+
* @param {Node} node
|
|
1262
|
+
* @returns {boolean}
|
|
1263
|
+
*/
|
|
1264
|
+
export function hasAnimate(node) {
|
|
1265
|
+
return hasCustomOrDataAttribute(node, "animate");
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* @ignore
|
|
1270
|
+
* @param {Node} node
|
|
1271
|
+
* @param {string} attr
|
|
1272
|
+
* @returns {boolean}
|
|
1273
|
+
*/
|
|
1274
|
+
function hasCustomOrDataAttribute(node, attr) {
|
|
1275
|
+
if (node.nodeType !== Node.ELEMENT_NODE) return false;
|
|
1276
|
+
const element = /** @type {HTMLElement} */ (node);
|
|
1277
|
+
return (
|
|
1278
|
+
element.dataset[attr] === "true" || element.getAttribute(attr) === "true"
|
|
1279
|
+
);
|
|
1280
|
+
}
|