Permalink
Browse files

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.
  • Loading branch information...
1 parent 2317af6 commit 1bebe36aa938890d61188762ed618b1b5e193634 @matsko matsko committed Mar 25, 2014
Showing with 344 additions and 240 deletions.
  1. +0 −5 css/angular.css
  2. +19 −5 src/ng/directive/ngShowHide.js
  3. +239 −222 src/ngAnimate/animate.js
  4. +86 −8 test/ngAnimate/animateSpec.js
View
@@ -9,8 +9,3 @@
ng\:form {
display: block;
}
-
-.ng-animate-block-transitions {
- transition:0s all!important;
- -webkit-transition:0s all!important;
-}
@@ -40,10 +40,10 @@
* restating the styles for the .ng-hide class in CSS:
* ```css
* .ng-hide {
- * //!annotate CSS Specificity|Not to worry, this will override the AngularJS default...
+ * /* Not to worry, this will override the AngularJS default...
* display:block!important;
*
- * //this is just another form of hiding an element
+ * /* this is just another form of hiding an element */
* position:absolute;
* top:-9999px;
* left:-9999px;
@@ -69,10 +69,20 @@
* //a working example can be found at the bottom of this page
* //
* .my-element.ng-hide-add, .my-element.ng-hide-remove {
- * transition:0.5s linear all;
+ * /* this is required as of 1.3x to properly
+ * apply all styling in a show/hide animation */
+ * transition:0s linear all;
+ *
+ * /* this must be set as block so the animation is visible */
* display:block!important;
* }
*
+ * .my-element.ng-hide-add-active,
+ * .my-element.ng-hide-remove-active {
+ * /* the transition is defined in the active class */
+ * transition:1s linear all;
+ * }
+ *
* .my-element.ng-hide-add { ... }
* .my-element.ng-hide-add.ng-hide-add-active { ... }
* .my-element.ng-hide-remove { ... }
@@ -109,8 +119,6 @@
</file>
<file name="animations.css">
.animate-show {
- -webkit-transition:all linear 0.5s;
- transition:all linear 0.5s;
line-height:20px;
opacity:1;
padding:10px;
@@ -123,6 +131,12 @@
display:block!important;
}
+ .animate-show.ng-hide-add.ng-hide-add-active,
+ .animate-show.ng-hide-remove.ng-hide-remove-active {
+ -webkit-transition:all linear 0.5s;
+ transition:all linear 0.5s;
+ }
+
.animate-show.ng-hide {
line-height:0;
opacity:0;
Oops, something went wrong.

0 comments on commit 1bebe36

Please sign in to comment.