angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

iOS CSS animation flicker ngAnimate

Open petalvlad opened this issue 12 years ago • 13 comments

Hey guys!

Has anybody experienced flicker effect like this?

output_optimized

Without ngAnimate there is no flicker but I lose other needed animations using ng-enter and ng-leave. So I need to stay with ngAnimate but get rid of the flicker.

This is only iOS issue, on Desktop browsers everything works fine.

Initial state of popup:

.fade-scale {   
  -webkit-transition: all .2s ease-in-out;
  -webkit-transform:scale(0.8);
  opacity:0; 
}

On tap it adds this class on popup

.show {
  -webkit-transform:scale(1);
  opacity:1;      
}

petalvlad avatar Aug 08 '14 13:08 petalvlad

Can you provide a minimal example for this?

Narretz avatar Aug 14 '14 19:08 Narretz

@petalvlad can you provide the whole css for that, including ng-enter, ng-leave, etc...

I have a similar issue that I'm trying to reproduce, but right now I have no success.

jberube avatar Aug 27 '14 20:08 jberube

You might want to try something like this:

 &.ng-enter {
    visibility: hidden;
    animation-name: fadeAndSlideFromTop;
    animation-play-state: paused;
    &.ng-enter-active {
      visibility: visible;
      animation-play-state: running;
    }
  }

from AngularMotion, if I remember correctly I added the animation-play-state stuff to fix latest safari and visibility to fix iOS flickering.

mgcrea avatar Sep 15 '14 22:09 mgcrea

From the main ngAnimate docs:

"Keep in mind that, by default, if an animation is running, any child elements cannot be animated until the parent element's animation has completed. This blocking feature can be overridden by placing the ng-animate-children attribute on a parent container tag."

gkalpak avatar Sep 25 '14 12:09 gkalpak

Noticing this flicker with a fade-out animation and ng-if. At the end of the animation the element briefly reappears before being removed from the DOM

chrisnicola avatar Feb 07 '15 00:02 chrisnicola

As I understand the logic the problem may be that all animation classes are removed from the element after the animation is completed but before it is removed from the DOM. This removal probably happens quickly enough not to matter in many situations but on iOS it appears that it doesn't. I'd suspect a similar problem exists with entering.

chrisnicola avatar Feb 07 '15 00:02 chrisnicola

Hi, i am experiencing the same problem on my ipad with iOS 8, on chrome and safari. chrisnicola, you are right. the documentation says that the element is inserted, then ngAnimate wait a digest and then it scan the element to see if there is an animation to play on it. And the ng-enter class is added. So there is a lot of operation between the moment where element is added to the DOM and the moment where the ng-enter class is added. So I think like you that on iOS things are slower and the browser have the time to render the element before the animation starts.

It is a very annoying issue

super-ienien avatar Feb 18 '15 00:02 super-ienien

@mgcrea Thank you so much! This flickering bug still exists and your code exactly solved the bug for iOS and Safari.

Fonger avatar Mar 08 '15 06:03 Fonger

@mgcrea 's solution helped some of my animations complete correctly, but did not ultimately resolve all my iOS flickering issues.

bradfx avatar May 19 '15 07:05 bradfx

@mgcrea - Thanks! This solved my problem with Safari flicker when using a slide in animation for a modal.

travisbmiller avatar May 29 '15 15:05 travisbmiller

@chrisnicola +1

I'm experiencing the same thing. The animation itself works exactly as it should, but when it'sa ll over, the element reappears for half a second or so.

laustdeleuran avatar Jun 15 '15 15:06 laustdeleuran

@chrisnicola From my own quick results, it seems that @mgcrea's solution works. This is what I have right now:

&.ng-animate {
    &.ng-leave,
    &.ng-enter {
        @include animation-play-state(paused !important);
    }
    &.ng-enter {
        visibility: hidden;
    }
    &.ng-leave-active,
    &.ng-enter-active {
        visibility: visible;

        @include animation-play-state(running !important);
    }
}

This seems to fix the ghosting / flicker problem on Mobile Safari for me. Will get back to you if this changes.

laustdeleuran avatar Jun 15 '15 16:06 laustdeleuran

If anyone is still experiencing this, please provide a running demo (plnkr.co) etc. and the iOs Safari versions etc. in which this happens, so we can test it.

Narretz avatar Jan 29 '16 13:01 Narretz