From 62a234e6e21397986733152b448e89ee0353dcfb Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 26 Jul 2019 15:16:26 +0000 Subject: [PATCH] [FIX] website: only stop clone's animations on cloning /!\ Should not be forward-ported ! As further explained, this commit is /!\ only partial backports of 12.0 commits. All conflicts should be /!\ ignored. A recently merged PR https://github.com/odoo/odoo/pull/35029 was in fact developed for 12.0 originally and finally merged in 11.0 to solve potential same bugs. The problem is that one line of that merge relied on a 12.0 feature that is missing in 11.0: the ability to stop animations *on part of the DOM only*. This commit chose to backport that 12.0 feature instead of retargeting the original PR as it will be needed for another unrelated fixes. So, this commit partially backport those commits: - https://github.com/odoo/odoo/commit/0a31cb9b4ae461119ecafdd05c5b979621ffb039 - https://github.com/odoo/odoo/commit/b56e647f2c540d34860cdee8a6adf0785ce3b8ef (Only the stop animation ability part, not the way it was used). Note that the first commit was already partially backported with https://github.com/odoo/odoo/commit/59e1bdff221f4a099f6000eb9884f84f772c38bb closes odoo/odoo#35230 Signed-off-by: Romain Derie (rde) --- .../static/src/js/content/website_root.js | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/addons/website/static/src/js/content/website_root.js b/addons/website/static/src/js/content/website_root.js index dee89b8be1b..3954dda6114 100644 --- a/addons/website/static/src/js/content/website_root.js +++ b/addons/website/static/src/js/content/website_root.js @@ -166,12 +166,21 @@ var WebsiteRoot = BodyManager.extend({ * in edition mode for example. * * @private + * @param {jQuery} [$from] + * only stop the animations linked to the given element(s) or one of + * its descendants */ - _stopAnimations: function () { - _.each(this.animations, function (animation) { - animation.destroy(); + _stopAnimations: function ($from) { + var removedAnimations = _.map(this.animations, function (animation) { + if (!$from + || $from.filter(animation.el).length + || $from.find(animation.el).length) { + animation.destroy(); + return animation; + } + return null; }); - this.animations = []; + this.animations = _.difference(this.animations, removedAnimations); }, //-------------------------------------------------------------------------- @@ -195,9 +204,10 @@ var WebsiteRoot = BodyManager.extend({ * stopped. * * @private + * @param {OdooEvent} ev */ - _onAnimationStopDemand: function () { - this._stopAnimations(); + _onAnimationStopDemand: function (ev) { + this._stopAnimations(ev.data.$target); }, /** * @todo review