This repository has been archived by the owner on May 29, 2019. It is now read-only.
fix(carousel): cancel goNext on scope destruction #1453
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem was that goNext be called after removeSlide when the slide's scope is destroyed. Since the destroy event is broadcasted, it fires on the parent before the child. As such what happens is:
Hence, the timer gets restarted by the slide's destroy event after the parent carousel's destroy event is fired.
Discovered after #1451
Note that the transition branch (if a transition is currently running and the scope is destroyed) isn't covered by the current tests but that will still work with this fix. Tests with transitions can get quite complicated because we don't have a helper to flush $transition events. However, I think this will be fixed very quickly once we switch over to ngAnimate. That's why I don't intend to complicate this code further as most of the code in the carousel will go away. For example, the whole goNext function will be gone if we can use the
$animate
service.