diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index 99678b34e93..2833e5b5318 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -426,27 +426,16 @@ var registry = {}; registry.slider = Animation.extend({ selector: '.carousel', + edit_events: { + 'slid.bs.carousel': '_onEditionSlide', + }, /** * @override */ start: function () { if (!this.editableMode) { - var maxHeight = 0; - var $items = this.$('.item'); - _.each($items, function (el) { - var $item = $(el); - var isActive = $item.hasClass('active'); - $item.addClass('active'); - var height = $item.outerHeight(); - if (height > maxHeight) { - maxHeight = height; - } - $item.toggleClass('active', isActive); - }); - _.each($items, function (el) { - $(el).css('min-height', maxHeight); - }); + this._computeHeights(); } this.$target.carousel(); return this._super.apply(this, arguments); @@ -458,10 +447,46 @@ registry.slider = Animation.extend({ this._super.apply(this, arguments); this.$target.carousel('pause'); this.$target.removeData('bs.carousel'); - _.each(this.$('.item'), function (el) { + _.each(this.$('.carousel-item'), function (el) { $(el).css('min-height', ''); }); }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * @private + */ + _computeHeights: function () { + var maxHeight = 0; + var $items = this.$('.carousel-item'); + _.each($items, function (el) { + var $item = $(el); + var isActive = $item.hasClass('active'); + $item.addClass('active'); + var height = $item.outerHeight(); + if (height > maxHeight) { + maxHeight = height; + } + $item.toggleClass('active', isActive); + }); + _.each($items, function (el) { + $(el).css('min-height', maxHeight); + }); + }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * @private + */ + _onEditionSlide: function () { + this._computeHeights(); + }, }); registry.parallax = Animation.extend({ diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index 55142cea2ca..13532104449 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -247,6 +247,10 @@ options.registry.carousel = options.Class.extend({ } }); _.defer(function () { + self.trigger_up('animation_start_demand', { + editableMode: true, + $target: self.$target, + }); self.$target.carousel(index > 0 ? --index : cycle); }); }