[FIX] website: restore carousel item behavior
The animation that made all the carousel items have the same height automatically was broken. This commit fixes it and improves its behavior during edition. closes odoo/odoo#27801
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user