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

ng-animate on ng-view doesn't remove previous page content with firefox

Open jmeiss opened this issue 13 years ago • 20 comments

Here is a fiddle to see the bug in action: http://jsfiddle.net/qSBHE/10/

When you navigate between pages with chrome and had a look at the source page, you will only see the destination page content. Ex:

<div ng-view="" ng-animate="'flip'">
  <a href="#/page2" class="ng-scope">page 2</a>
</div>

but when you do the same thing with firefox, all pages are append. Ex:

<div ng-animate="'flip'" ng-view="">
  <a href="#/page1" class="flip-enter-setup ng-scope flip-enter-start flip-leave-setup flip-leave-start">page 1</a>
  <a href="#/page2" class="flip-enter-setup ng-scope flip-enter-start flip-leave-setup flip-leave-start">page 2</a>
  <a href="#/page3" class="flip-enter-setup ng-scope flip-enter-start flip-leave-setup flip-leave-start">page 3</a>
  <a href="#/page2" class="flip-enter-setup ng-scope flip-enter-start flip-leave-setup flip-leave-start">page 2</a>
  <a href="#/page3" class="flip-enter-setup ng-scope flip-enter-start flip-leave-setup flip-leave-start">page 3</a>
  <a href="#/page1" class="flip-enter-setup ng-scope flip-enter-start">page 1</a>
</div>

jmeiss avatar Apr 26 '13 11:04 jmeiss

+1 -- did not expect anything this bad when checking my ng-animates in FF. Sheesh!

klebba avatar May 11 '13 00:05 klebba

This looks like a bug with the transition end event -- check out my updated fiddle which works:

http://jsfiddle.net/qSBHE/16/

klebba avatar May 11 '13 01:05 klebba

@klebba your fiddle doesn't work for me. Ok, the page 1 is not anymore visible but if I go to page 2 then inspect the source, I can see that the link is still here as you can see on the attached screenshot.

screen shot 2013-05-11 at 16 41 47

jmeiss avatar May 11 '13 14:05 jmeiss

Sorry -- I updated the fiddle to 16, but I'm guessing when GitHub emailed you it was still 13 -- try this:

http://jsfiddle.net/qSBHE/16/

Basically I could reproduce/eliminate the problem by adding/removing the 'leave' transition in FF. It seems like a bug in Angular related to CSS transitions. I will continue to investigate but I did see that the Yearofmoo demonstration app also does not use the 'leave' transition on ng-view so it might be known already by @matsko -- though I havent seen any reported issues that are obviously related. I wound up doing this in my controller:

$scope.leaveAni = $sniffer.vendorPrefix === 'Webkit' ? 'view-leave' : false;

and this in my view:

<div ng-view ng-animate="{enter:'view-enter',leave:leaveAni}"></div>

$sniffer is an undocumented service available in the Angular core. Not ideal!

--C

klebba avatar May 11 '13 20:05 klebba

@jmeiss -- check this fiddle I made:

http://jsfiddle.net/klebba/7Bw8W

I'm using a service to watch the transitionEnd event in JavaScript and manipulate the CSS classnames in the same way as the default behavior. You can drop this service into your project transparently until there is a fix.

If you have any questions, don't hesitate to ask!

--C

klebba avatar May 17 '13 23:05 klebba

It seems to be a good workaround and I will probably use it when I will add animation to my application ;)

(it was only a POC)

Thank you very much!

jmeiss avatar May 23 '13 18:05 jmeiss

+1 ngAnimate is useless until this is fixed

jasadams avatar May 28 '13 19:05 jasadams

As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months.

Please try the newest versions of Angular (1.0.8 and 1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.

Thanks!

btford avatar Aug 24 '13 00:08 btford

This is happening for me. When I define css for .ng-enter and/or .ng-leave on [ng-view], my views are appended one after the other in Firefox, and do not remove. When I don't define the classes, things work normally. Adding the animations kills whatever logic exists to remove a view that has "left."

Tathanen avatar Nov 26 '13 18:11 Tathanen

I have this problem. Everything works perfectly in chrome, however in firefox ng-views are appended one after the other.

Any fix?

devsmm avatar Jan 29 '15 13:01 devsmm

Right now ngAnimate has a big refactoring going on. I'm happy to deal with this directly during that refactor. Seeing as it is still an issue, I'm going to reopen this.

matsko avatar Jan 29 '15 14:01 matsko

I just found out that the problem was a failure within a directive. I have element.on ('$ destroy', function () {            document.removeEventListener (visibilityChange);          });

In firefox, two arguments is necessary in removeEventListener and the transition stopped.

Thanks and sorry.

devsmm avatar Jan 29 '15 16:01 devsmm

OK. Thanks for the info. Why did you not use $(document).off(...) instead?

matsko avatar Jan 29 '15 16:01 matsko

Yes, i should use that.

Thanks.

devsmm avatar Jan 29 '15 16:01 devsmm

@matsko - can we put this in a milestone? If you are actively working on it then I would think 1.4.x or even 1.4.0-beta.3 / 1.3.12

petebacondarwin avatar Jan 29 '15 21:01 petebacondarwin

I am experiencing the same issue in both chrome and firefox. I am using version 1.2.19.

aaani avatar Feb 19 '15 02:02 aaani

Same here, even with latest v1.4.0-beta.5

melino avatar Mar 03 '15 23:03 melino

@matsko - is this fixed with the new animation engine?

petebacondarwin avatar Apr 27 '15 13:04 petebacondarwin

By the looks of it, things are working as expected with 1.4:

http://plnkr.co/edit/38upnPJqcLdMGUkoveZn?p=preview

And with 1.3:

http://plnkr.co/edit/5sjlneFawUPU52CURl3V?p=preview

Am I missing something here? It looks like the views are being removed correctly in both versions on Chrome and Firefox.

matsko avatar May 06 '15 17:05 matsko

I'm closing this issue for now since I can't get a reproduction to work. Please reopen if it's still an issue.

matsko avatar May 11 '15 19:05 matsko