From 6920b50ffe67b02171278943da56d6c0178810a6 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 12 Sep 2019 12:29:37 +0200 Subject: [PATCH] done #3038 @0.5 --- resources/js/carrousel.js | 12 +++++------- resources/styles/components/carrousel.styl | 2 -- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/resources/js/carrousel.js b/resources/js/carrousel.js index d17456f..5b9251f 100644 --- a/resources/js/carrousel.js +++ b/resources/js/carrousel.js @@ -28,10 +28,11 @@ window.Hammer = Hammer.default; this.getImg.src = this.element.find('.img-slider').attr("src"); this.img = this.element.find('.img-slider'); + this.imgWidth = this.getImg.naturalWidth; + this.width = this.img.width(); // --> clip container width + this.height = this.img.height(); // --> clip container height - this.width = this.element.find('.slide-img').width(); // --> clip container width - this.height = this.element.find('.slide-img').height(); // --> clip container height this.initRect = 'rect(0px '; this.finalRect = 'px 0px)'; @@ -94,7 +95,7 @@ window.Hammer = Hammer.default; resize: function () { let $this = this; - var cw = this.element.outerWidth() / 2; + var cw = this.element.find('.slider').width() / 2; var ch = 720; @@ -102,9 +103,6 @@ window.Hammer = Hammer.default; let naturalHeight = $(this).prop('naturalHeight'), naturalWidth = $(this).prop('naturalWidth'); - let getAllImg = new Image(); - getAllImg.src = $(this).attr("src"); - let widthFactor = cw / naturalWidth, // coef multiplicateur width heightFactor = ch / naturalHeight; // coef multiplicateur height @@ -112,7 +110,7 @@ window.Hammer = Hammer.default; var iw = naturalWidth * factor; var ih = naturalHeight * factor; - var left = (cw * 0.5) + (cw - iw) / 2; + var left = (cw - iw) / 2; var top = (ch - ih) / 2; $(this).css({ diff --git a/resources/styles/components/carrousel.styl b/resources/styles/components/carrousel.styl index 58db0c0..b45fa05 100644 --- a/resources/styles/components/carrousel.styl +++ b/resources/styles/components/carrousel.styl @@ -41,8 +41,6 @@ $breakpoint-carousel = 768px .img-slider position: absolute - left: 50% - transform: translateX(-50%) .slider width: 100% -- 2.39.5