From f4f89c68d0ccd89f522efb9a67dfd44534bef747 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 9 Sep 2019 16:46:18 +0200 Subject: [PATCH] fix #3017 @0:05 --- resources/js/carrousel.js | 17 +++++++++++------ resources/views/pages/home.blade.php | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/resources/js/carrousel.js b/resources/js/carrousel.js index 6a35dba..e239c51 100644 --- a/resources/js/carrousel.js +++ b/resources/js/carrousel.js @@ -14,7 +14,11 @@ window.Hammer = Hammer.default; this.slideLength = this.element.find(".slide").length; this.transitionning = false; - this.automode = true; + this.automode = this.slideLength > 1; + + if (this.slideLength <= 1) { + this.element.find('.slider-control,.slider-indicator').hide(); + } this.prevBtn = this.element.find(".home-arrow-left"); this.nextBtn = this.element.find(".home-arrow-right"); @@ -69,9 +73,11 @@ window.Hammer = Hammer.default; this.autoSlideDuration = 8; // automatic slideshow delay this.resize(); - this.initSwipeEvent(); - this.enableArrows(); - this.indicator(); + if (this.slideLength > 1) { + this.initSwipeEvent(); + this.enableArrows(); + this.indicator(); + } }, automaticSlideshow: function () { @@ -90,7 +96,6 @@ window.Hammer = Hammer.default; var cw = this.element.outerWidth() / 2; var ch = 720; - console.log(cw, ch); this.element.find('.img-slider').each(function () { let naturalHeight = $(this).prop('naturalHeight'), @@ -103,7 +108,7 @@ window.Hammer = Hammer.default; heightFactor = ch / naturalHeight; // coef multiplicateur height var factor = Math.max(widthFactor, heightFactor); - console.log(factor); + var iw = naturalWidth * factor; var ih = naturalHeight * factor; var left = (cw * 0.5) + (cw - iw) / 2; diff --git a/resources/views/pages/home.blade.php b/resources/views/pages/home.blade.php index 02caa75..8f68753 100644 --- a/resources/views/pages/home.blade.php +++ b/resources/views/pages/home.blade.php @@ -45,6 +45,7 @@ + @break @endforeach