summaryrefslogtreecommitdiff
path: root/addons/website/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/website/static/src')
-rw-r--r--addons/website/static/src/snippets/s_image_gallery/000.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/addons/website/static/src/snippets/s_image_gallery/000.js b/addons/website/static/src/snippets/s_image_gallery/000.js
index be0553aa56a..b86fbff652f 100644
--- a/addons/website/static/src/snippets/s_image_gallery/000.js
+++ b/addons/website/static/src/snippets/s_image_gallery/000.js
@@ -86,7 +86,18 @@ const GallerySliderWidget = publicWidget.Widget.extend({
this.$prev = this.$indicator.find('li.o_indicators_left').css('visibility', ''); // force visibility as some databases have it hidden
this.$next = this.$indicator.find('li.o_indicators_right').css('visibility', '');
var $lis = this.$indicator.find('li[data-slide-to]');
- var nbPerPage = Math.floor(this.$indicator.width() / $lis.first().outerWidth(true)) - 3; // - navigator - 1 to leave some space
+ let indicatorWidth = this.$indicator.width();
+ if (indicatorWidth === 0) {
+ // An ancestor may be hidden so we try to find it and make it
+ // visible just to take the correct width.
+ const $indicatorParent = this.$indicator.parents().not(':visible').last();
+ if (!$indicatorParent[0].style.display) {
+ $indicatorParent[0].style.display = 'block';
+ indicatorWidth = this.$indicator.width();
+ $indicatorParent[0].style.display = '';
+ }
+ }
+ let nbPerPage = Math.floor(indicatorWidth / $lis.first().outerWidth(true)) - 3; // - navigator - 1 to leave some space
var realNbPerPage = nbPerPage || 1;
var nbPages = Math.ceil($lis.length / realNbPerPage);