diff options
Diffstat (limited to 'addons/website/static/src/js/content/website_root.js')
| -rw-r--r-- | addons/website/static/src/js/content/website_root.js | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/addons/website/static/src/js/content/website_root.js b/addons/website/static/src/js/content/website_root.js index 336ea822902..29163838f7a 100644 --- a/addons/website/static/src/js/content/website_root.js +++ b/addons/website/static/src/js/content/website_root.js @@ -137,27 +137,22 @@ var WebsiteRoot = BodyManager.extend({ */ _startAnimations: function (editableMode, $from) { var self = this; + editableMode = editableMode || false; if ($from === undefined) { $from = this.$('#wrapwrap'); } + + this._stopAnimations($from); + var defs = _.map(sAnimation.registry, function (Animation, animationName) { var selector = Animation.prototype.selector || ''; var $target = $from.find(selector).addBack(selector); var defs = _.map($target, function (el) { - var $snippet = $(el); - var animationIndex = _.findIndex(self.animations, function (animation) { - return animation.__name === animationName && $snippet[0] === animation.el; - }); - if (animationIndex >= 0) { - self.animations[animationIndex].destroy(); - self.animations.splice(animationIndex, 1); - } var animation = new Animation(self, editableMode); - animation.__name = animationName; self.animations.push(animation); - return animation.attachTo($snippet); + return animation.attachTo($(el)); }); return $.when.apply($, defs); }); @@ -168,12 +163,15 @@ var WebsiteRoot = BodyManager.extend({ * in edition mode for example. * * @private - * @param {jQuery} [$stopTarget] - * only stop the animations linked to the given element(s) + * @param {jQuery} [$from] + * only stop the animations linked to the given element(s) or one of + * its descendants */ - _stopAnimations: function ($stopTarget) { + _stopAnimations: function ($from) { var removedAnimations = _.map(this.animations, function (animation) { - if (!$stopTarget || $stopTarget.filter(animation.el).length) { + if (!$from + || $from.filter(animation.el).length + || $from.find(animation.el).length) { animation.destroy(); return animation; } |
