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

ng-hide and ng-show showing at the same time for a short period of time in IE11 #14015

Open
PhilipWallin opened this issue Feb 12, 2016 · 45 comments

Comments

@PhilipWallin
Copy link

When including ng-animate there seem to be a brief period of time where a ng-show and ng-hide element are showing at the same time, even if no animations are used.

Example (the problem is only visible if using IE11):
http://plnkr.co/edit/vqVGcf9cjFQPAbq0Igyq?p=preview

In the example you can see the flickering of the two elements showing at the same time when checking and unchecking the checkbox which trigger ng-show/ng-hide.

@Narretz
Copy link
Contributor

Narretz commented Feb 12, 2016

This sounds familiar. The problem is that I can never reliably reproduce these in IE11. It has happened maybe once in 30 times for me. I've also seen it once on Firefox, so it maybe has something to do with how fast the browser flushed the requestAnimationFrame queue, or with how long we take to detect if animations are allowed.

@Narretz
Copy link
Contributor

Narretz commented Feb 12, 2016

Can you please test with the latest snapshot: http://code.angularjs.org/snapshot/angular-animate.js and see if it happens less often?

@PhilipWallin
Copy link
Author

In my IE11 I get the flash of both showing every time I click the checkbox. Using the linked angular-animate didn't seem to change this behavior.

@Narretz
Copy link
Contributor

Narretz commented Feb 12, 2016

That's weird. What IE and OS version do you have? And is your computer generally slow or under load?

@PhilipWallin
Copy link
Author

We have quite high-end computers (I tried on three of them), my initial guess was actually that it was fast enough to show something which is only visible for a short amount of time. I'm running Windows 8.1 with IE version 11.0.9600.18202. One of the computers I tried it on was Windows 7, showing the same problem.

@PhilipWallin
Copy link
Author

I'm currently applying this css to avoid the problem:
.ng-hide.ng-hide-animate {
display: none !important;
}

This could of course cause problems for us in the future if we want to animate some ng-hide and not animate some.

@Narretz
Copy link
Contributor

Narretz commented Feb 12, 2016

Hm, I didn't think about the computer being too fast. That could it be it. I also have a slightly newer version of IE11 (11.0.9600.18204), but I doubt that this is the reason.

@PhilipWallin
Copy link
Author

I tried this now in IE11 on my virtual Windows 7, and experience the problem maybe once every 2-10 try. This could be because my virtual machine is running slower, but this is only a guess.

@dgieselaar
Copy link

I'm having the same problem in Chrome, w/ an ng-switch. The specific case where it happens is when a view value change in ngModel is committed, which a) removes a ng-valid-parse class on the parent form, b) removes a class on the form field (a custom empty class) and b) flips an ng-switch (because the form field is then disabled). It happens because the parent animation (a) task runs first, and the scheduler waits until it is completed, then requests another frame to run the task from the form field (b), then waits another frame to run the ng-switch animation task (c), causing a flicker of one frame where both the elements in the ng-switch are temporarily displayed.

@dgieselaar
Copy link

image

@Narretz
Copy link
Contributor

Narretz commented Mar 5, 2016

@Plestik can you post a demo in a plnkr.co or similar?

@dgieselaar
Copy link

@Narretz I'll give it a shot. But is this even supposed to work w/ nested animations if it only runs one group of animations every frame?

@dgieselaar
Copy link

Sorry, can't reproduce it in a Plunkr.

@dgieselaar
Copy link

@Narretz is there anything I can do to help resolve this issue? If you want to, I can provide you w/ login credentials for our staging environment where I can reproduce it consistently.

Edit: I missed the part of the docs where it quite clearly says that combining structural animations w/ class animations can lead to flickering. Never mind me, then.

@adamreisnz
Copy link

I am experiencing similar issues on Chrome with OS X. In my case it's two ng-show's with distinct display conditions (which are never true at the same time). Even if I toggle the two conditions immediately after one another, there is a brief moment where both elements are visible. This doesn't happen in all page configurations, but happens pretty consistently in one particular case.

@chillyistkult
Copy link

chillyistkult commented Sep 8, 2016

I also have the same issue in Chrome on Windows, using angular and angular-animate 1.4.12.

@PhilipWallin solution is a good workaround for now.

@benbabics
Copy link

I'm experiencing the same issue in the iOS Simulator for iOS 9.3. I have uploaded a video demonstrating the issue: https://youtu.be/C0Lh5B1Lj6k

@Dhineshin
Copy link

Dhineshin commented Sep 29, 2016

I recently got my hands dirty using Angular material and included in my existing project and started experiencing this flickering behavior in Chrome while using ng-if/ng-show. After some trail and error found the issue caused due to "ngAnimate".

@PhilipWallin solution works as a workaround for me and not sure what would not work in future.

Just added the below in my CSS and replaced my "ng-if" to "ng-show"
.ng-hide.ng-hide-animate {
display: none !important;
}

P.S : using Angular and ngAnimate version v1.5.7

@bzitzow
Copy link

bzitzow commented Oct 18, 2016

+1

@garycuthbert
Copy link

Hi, I am experiencing a similar issue with angular 1.5.8 (having just upgraded from v 1.12.15).

The problem is very apparent under IE11, it is there under Chrome also but more often than not the transition is too fast to notice.

The directive i have is a tab control that uses transclusion to include tab pages. The flicker i am experiencing (which briefly shows the new and old active tab page html side by side) is when the user switches between tabs (i.e. after compilation and template loading). The code uses ng-show with a boolean flag to decide whether or not to display the page (of which a maximum of 1 is active at any one time).
If i replace ng-show with ng-if there is no flicker.

The work around i had been planning to use was to use ng-class with the same ng-show conditional flag to activate a custom css class '.myCloak { display: none !important}' (i.e. the same css used by ng-cloak) e.g.
ng-show="tab.active" ng-class="{'myCloak' : tab.active}" which does work around the problem.

I will attempt to create a plunkr to demonstrate but it may take a while.

In the meantime i will attach a screen shot of the issue as it appears in our app under IE11 and the video it was taken from.

ng-show_issue_01

On the screen shot the area within the thin red rounded rectangles show the tab page that is incorrectly being displayed and the relevant DOM inspection. The blue rounded rectangle areas highlight the active tab which is also shown.

By playing the video [http://take.ms/czZZV] you will see that it is not consistent but it does happen often.

@maxnathaniel
Copy link

I have the same issue on chrome 54 with Angular 1.5.8.

@PhilipWallin solution works for now too.

Any idea what the cause could be?

@garycuthbert
Copy link

Hello, I have managed to put together a plunk showing this behavior:

[https://plnkr.co/edit/PTrvz8]

If you run it under IE11 and switch between the tab pages you should see it. The code is a little ugly but it shows the problem. If you uncomment the ng-hide-animate override in style.css ( @PhilipWallin work around) the problem goes away.

I will tidy this up on monday and post a video of the problem using the plunk in case you still can't reproduce. Hope this helps...

@garycuthbert
Copy link

garycuthbert commented Oct 31, 2016

I have tidied up the plunk a little and added a description,
https://plnkr.co/edit/l70kaJ
there are blue and red borders around the respective tab pages to make the double rendering move obvious (under IE11)

@garycuthbert
Copy link

As @teterovic discovered in issue #13974 this behavior seems to have be introduced in version 1.4.5. If you change the angular and angular-animate versions on the plunk to 1.4.4 the behavior is not there, up it to 1.4.5 and it appears.

@Narretz
Copy link
Contributor

Narretz commented Nov 1, 2016

@garycuthbert Thanks for the plnkr, it shows the issue very well (in IE11). I will investigate and see if there's anything we can do.
In the meantime, if you don't actually use animations on the elements, you can the classNameFilter to disable animations on that element: https://code.angularjs.org/snapshot/docs/api/ng/provider/$animateProvider#classNameFilter

@Narretz Narretz added this to the 1.5.x milestone Nov 1, 2016
@fashaikh2021
Copy link

fashaikh2021 commented Dec 20, 2016

Hi Narretz,
I have been trying to fix this issue from a while and found this patch here which after applied have fixed the problem for the version 1.5.0.Beta something, but still not working with 1.5.8. Thanks for the path :)

Also in the patch I noticed at once double equal '==' has been used where after changing it to '===' it works. Which is correct syntax for condition check.

I also have tried this in further version 1.5.9 and 1.6.0, it's not still working with patch anyway. Any help will be highly appreciable.

Thanks
Fahad

@gkalpak gkalpak closed this as completed Dec 20, 2016
@gkalpak gkalpak reopened this Dec 20, 2016
@Narretz
Copy link
Contributor

Narretz commented Dec 21, 2016

I will review @gkalpak's PR after Christmas, and then we can hopefully get it in quickly.

@fashaikh2021
Copy link

Tried in further versions not working in 1.5.9 and 1.6.1. Any help / suggestion will be highly appreciable. Thanks
Fahad

@mmomeni
Copy link

mmomeni commented Jan 30, 2017

Still the same issue with 1.5.10

@stijn26
Copy link

stijn26 commented Mar 7, 2017

Had the same issue, wanted to try to upgrade to 1.6.1 from 1.3.x and had to downgrade again to 1.4.4. What an embarrasment for the Angular team

@ghost
Copy link

ghost commented Mar 7, 2017

@stijn26 you did probably something wrong and this should be an stackoverflow question but anyway:

  • 1.6 has breaking changes when compared with 1.X-1.5 please consider them - you can see the changes in the changelog on github (try 1.5 instad)
  • Did you update all the modules ? like angular-animate.js to the corresponding revision or just angular.min.js ? if not try it

@stijn26
Copy link

stijn26 commented Mar 7, 2017

I checked all breaking changes and modified them, all modules were updated. I had the exact same issue as the rest of the persons in this thread.

@fashaikh2021
Copy link

fashaikh2021 commented Mar 7, 2017

@mmomeni @stijn26 @teterovic
For now, we found the work around which is to turn on and off the animate & it's working fine for us so far. example is below. Hope it may help you guys too until team find the right fix ???

$animate.enabled(false);
    $scope.$on('$destroy',
        function() {
            $animate.enabled(true);
        });

@Narretz Narretz modified the milestones: 1.5.x, 1.6.x Mar 31, 2017
@samal-rasmussen
Copy link

I'm getting this flicker with ng-show on angular 1.6.3 on Chrome 57 on Windows 7. The display: none on .ng-hide.ng-hide-animate fixes it for me.

@Narretz
Copy link
Contributor

Narretz commented Apr 21, 2017

@samal84 can you please provide a demo? I cannot reproduce this in Chrome 58 with the plnkr in the first post updated to 1.6.4.

@samal-rasmussen
Copy link

Ok it looks more like a bug with angular material md-switch, now that I tried to make a minimal demo: http://plnkr.co/edit/hR2B8yEPjak0v2Yryid1?p=preview

Try clicking the switch quickly, and you should see that on/off inside and outside the md-switch behave differently. The one inside flickers with both being rendered for a split second, while the one outside is fine.

@vbraun
Copy link
Contributor

vbraun commented May 5, 2017

@samal84 That is also fixed by disabling $animate (which angular-material uses). Demo:
http://plnkr.co/edit/C08HPffIBTomH1QoBdRD?p=preview

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.