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

scope is destroyed too early for ngView and ngInclude causing ngClass not to update #6974

Open
matsko opened this issue Apr 3, 2014 · 14 comments

Comments

@matsko
Copy link
Contributor

matsko commented Apr 3, 2014

A popular animation trick is to perform a back and forward-style animation in using ngClass on a ngView or ngInclude element. This used to work with older versions of ngAnimate (pre 1.2) since ngAnimate didn't use CSS classes for animations.

Right now if you try and perform an animation that, when the route changes, updates ngClass and triggers the leave animation to be different, it won't reflect on the leaving element. This is because ngView and ngInclude both destroy the scope first and then trigger the animation. However, since an extra digest is required for a class to update via ngClass upon routeChange, the newly updated CSS classes won't show up in the element.

Therefore, we need to fix ngView and ngInclude to destroy the scope after a single digest loop via $$postDigest or something.

Dupes: #7515

@matsko matsko changed the title scope is destroyed too early for ngView and ngInclude casuing ngClass not to update scope is destroyed too early for ngView and ngInclude causing ngClass not to update Apr 3, 2014
@btford
Copy link
Contributor

btford commented Apr 3, 2014

@matsko please triage your own issues. 😄

@IgorMinar
Copy link
Contributor

was this always an issue or is this a regression?

@mhevery
Copy link
Contributor

mhevery commented Apr 4, 2014

Sounds like we need to delay removal until after digest.

@matsko
Copy link
Contributor Author

matsko commented Apr 4, 2014

The problem came from here: https://groups.google.com/forum/#!topic/angular/iKpRhrPr8ko

@matsko
Copy link
Contributor Author

matsko commented Apr 4, 2014

@IgorMinar always an issue once we started to rely on class="..." to detect animations.

@IgorMinar
Copy link
Contributor

btw $destroy is now quite destructive. it even blows away $asyncEval and $$postDigest queues.

@IgorMinar
Copy link
Contributor

+1 for what @btford said. please triage this issue so that others don't have to do it, you already understand the issue and can label it within a few seconds while others have to read and try to understand it.

@matsko matsko added this to the 1.3.0-beta.6 milestone Apr 4, 2014
@matsko matsko self-assigned this Apr 4, 2014
@matsko
Copy link
Contributor Author

matsko commented Apr 4, 2014

@IgorMinar done.

@IgorMinar
Copy link
Contributor

It sounds like we have three options:

1/ use postDigest to trigger a new apply and destroy the scopes there (it has to be an apply because destroy might change the model) - this could be an expensive.
2/ find a way to flush the class binding on the node being removed - this would be more efficient but kind of breaks many other guarantees of the digest cycle
3/ use evalAsync to destroy the scopes and remove nodes and hope that the class binding will get its proper value during the first iteration

2/ and 3/ have many issues so can we try 1/?

@IgorMinar IgorMinar reopened this May 9, 2014
@caitp caitp modified the milestones: 1.3.0-beta.9, 1.3.0-beta.8 May 9, 2014
@IgorMinar IgorMinar modified the milestones: 1.3.0, 1.3.0-beta.9 May 12, 2014
@btford btford added this to the 1.3.0-beta.14 milestone Jun 30, 2014
@jeffbcross jeffbcross modified the milestones: 1.3.0, 1.3.0-rc.3 Sep 22, 2014
@jeffbcross jeffbcross modified the milestones: 1.3.0-rc.5, 1.3.0 Sep 29, 2014
@IgorMinar IgorMinar self-assigned this Oct 1, 2014
@btford btford modified the milestones: 1.3.0-rc.5, 1.3.0-rc.6 Oct 8, 2014
@IgorMinar IgorMinar modified the milestones: 1.3.0-rc.6, 1.3.0 Oct 13, 2014
@tbosch tbosch modified the milestones: 1.3.x, 1.3.1, Backlog Oct 15, 2014
@gitnik
Copy link

gitnik commented Jun 15, 2016

Any update on this?

@halfong
Copy link

halfong commented Jun 24, 2016

To me, solved by change the leaving ngView dom's class manually ( use zeptojs ) .

@kevineger
Copy link

Has this been resolved?

@gkalpak
Copy link
Member

gkalpak commented Sep 22, 2016

If people want a class-based, leave animation for ngView, why not use the "standard" ng-leave[-active] classes?

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