]> _ Git - pmi.git/commitdiff
done #3038 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 12 Sep 2019 10:29:37 +0000 (12:29 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 12 Sep 2019 10:29:37 +0000 (12:29 +0200)
resources/js/carrousel.js
resources/styles/components/carrousel.styl

index d17456f0970a024df77171f7ca62e59a6f8bb68c..5b9251f25e7f18777404c7adb98fe67d1bf38dc1 100644 (file)
@@ -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({
index 58db0c0af00088a81f787e8dd993bd16336f18e7..b45fa051dfa52443fc6f5bd57c357d85b394b288 100644 (file)
@@ -41,8 +41,6 @@ $breakpoint-carousel = 768px
 
   .img-slider
     position: absolute
-    left: 50%
-    transform: translateX(-50%)
 
   .slider
     width: 100%