Skip to content

Commit 09d2c15

Browse files
committed
On popView add control the name of animation end
1 parent df70784 commit 09d2c15

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "backbone.viewstack",
3-
"version": "1.0.12",
3+
"version": "1.0.13",
44
"homepage": "https://github.com/vash15/backbone.viewstack",
55
"authors": [
66
"Michele Belluco <michele@belluco.info>",

lib/viewstack.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,24 @@ var ViewStack = module.exports = Backbone.View.extend({
149149

150150
self._popView(poppedView, false);
151151

152-
poppedView.$el.one('webkitAnimationEnd mozAnimationEnd msAnimationEnd animationend', function (e) {
153-
poppedView.trigger('pop');
154-
poppedView.destroy();
155-
poppedView.trigger("deactive");
156-
});
152+
if ( !options.animatedName ){
153+
poppedView.$el.one('webkitAnimationEnd mozAnimationEnd msAnimationEnd animationend', function (e) {
154+
poppedView.trigger('pop');
155+
poppedView.destroy();
156+
poppedView.trigger("deactive");
157+
});
158+
}else{
159+
// Viene usata nei casi di più animazioni nella view. Cos' mi assicuro di distruggerla solo dopo aver
160+
// terminato l'animazione desiderata
161+
poppedView.$el.on('webkitAnimationEnd mozAnimationEnd msAnimationEnd animationend', function (e) {
162+
if ( e && e.originalEvent && e.originalEvent.animationName == options.animatedName ){
163+
poppedView.$el.off('webkitAnimationEnd mozAnimationEnd msAnimationEnd animationend');
164+
poppedView.trigger('pop');
165+
poppedView.destroy();
166+
poppedView.trigger("deactive");
167+
}
168+
});
169+
}
157170
poppedView.$el.addClass('pop');
158171

159172
return poppedView;

0 commit comments

Comments
 (0)