Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 1bebe36

Browse files
committed
fix($animate): make CSS blocking optional for class-based animations
$animate attempts places a `transition: none 0s` block on the element when the first CSS class is applied if a transition animation is underway. This works fine for structural animations (enter, leave and move), however, for class-based animations, this poses a big problem. As of this patch, instead of $animate placing the block, it is now the responsibility of the user to place `transition: 0s none` into their class-based transition setup CSS class. This way the animation will avoid all snapping and any will allow $animate to play nicely with class-based transitions that are defined outside of ngAnimate. Closes #6674 Closes #6739 BREAKING CHANGE: Any class-based animation code that makes use of transitions and uses the setup CSS classes (such as class-add and class-remove) must now provide a empty transition value to ensure that its styling is applied right away. In other words if your animation code is expecting any styling to be applied that is defined in the setup class then it will not be applied "instantly" default unless a `transition:0s none` value is present in the styling for that CSS class. This situation is only the case if a transition is already present on the base CSS class once the animation kicks off.
1 parent 2317af6 commit 1bebe36

File tree

4 files changed

+344
-240
lines changed

4 files changed

+344
-240
lines changed

css/angular.css

-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,3 @@
99
ng\:form {
1010
display: block;
1111
}
12-
13-
.ng-animate-block-transitions {
14-
transition:0s all!important;
15-
-webkit-transition:0s all!important;
16-
}

src/ng/directive/ngShowHide.js

+19-5
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
* restating the styles for the .ng-hide class in CSS:
4141
* ```css
4242
* .ng-hide {
43-
* //!annotate CSS Specificity|Not to worry, this will override the AngularJS default...
43+
* /* Not to worry, this will override the AngularJS default...
4444
* display:block!important;
4545
*
46-
* //this is just another form of hiding an element
46+
* /* this is just another form of hiding an element */
4747
* position:absolute;
4848
* top:-9999px;
4949
* left:-9999px;
@@ -69,10 +69,20 @@
6969
* //a working example can be found at the bottom of this page
7070
* //
7171
* .my-element.ng-hide-add, .my-element.ng-hide-remove {
72-
* transition:0.5s linear all;
72+
* /* this is required as of 1.3x to properly
73+
* apply all styling in a show/hide animation */
74+
* transition:0s linear all;
75+
*
76+
* /* this must be set as block so the animation is visible */
7377
* display:block!important;
7478
* }
7579
*
80+
* .my-element.ng-hide-add-active,
81+
* .my-element.ng-hide-remove-active {
82+
* /* the transition is defined in the active class */
83+
* transition:1s linear all;
84+
* }
85+
*
7686
* .my-element.ng-hide-add { ... }
7787
* .my-element.ng-hide-add.ng-hide-add-active { ... }
7888
* .my-element.ng-hide-remove { ... }
@@ -109,8 +119,6 @@
109119
</file>
110120
<file name="animations.css">
111121
.animate-show {
112-
-webkit-transition:all linear 0.5s;
113-
transition:all linear 0.5s;
114122
line-height:20px;
115123
opacity:1;
116124
padding:10px;
@@ -123,6 +131,12 @@
123131
display:block!important;
124132
}
125133
134+
.animate-show.ng-hide-add.ng-hide-add-active,
135+
.animate-show.ng-hide-remove.ng-hide-remove-active {
136+
-webkit-transition:all linear 0.5s;
137+
transition:all linear 0.5s;
138+
}
139+
126140
.animate-show.ng-hide {
127141
line-height:0;
128142
opacity:0;

0 commit comments

Comments
 (0)