]> _ Git - pmi.git/commitdiff
wip #2747 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 9 Sep 2019 09:18:13 +0000 (11:18 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 9 Sep 2019 09:18:13 +0000 (11:18 +0200)
resources/js/carrousel.js
resources/styles/components/carrousel.styl
resources/views/pages/home.blade.php

index 8ac09e2ae7eaef13eec145d963fc604ab0c6d9b8..745b7e3d67e17bef6ab08715a1b29b2afee720e3 100644 (file)
@@ -6,7 +6,6 @@ window.Hammer = Hammer.default;
 
 (function ($) {
     function JQPMISlide(element) {
-        console.log(':))', element);
         this.element = element;
         this.pmiSlider = this.element.get(0);
         this.hammerSwipe = new Hammer(this.pmiSlider);
@@ -26,16 +25,31 @@ window.Hammer = Hammer.default;
 
         this.width = this.element.find('.slide-img').width(); // --> clip container width
         this.height = this.element.find('.slide-img').height(); // --> clip container height
-        this.init = 'rect(0px ';
-        this.final = 'px 0px)';
+        this.initRect = 'rect(0px ';
+        this.finalRect = 'px 0px)';
 
         this.container = this.element.find('.slider');
         this.hammerSwipe.get('swipe').set({enable: true});
-        this.initt();
+        this.init();
     };
 
     JQPMISlide.prototype = {
-        initt: function () {
+        init: function () {
+            var $this = this;
+            var i = 0;
+            this.container.find(".slide").each(function () {
+                console.log(this);
+                if (i === 0) {
+                    $(this).addClass('active').removeClass('hide');
+                } else {
+                    $(this).addClass('hide').removeClass('active');
+                }
+                $this.container.find('.slider-indicator ul').append('<li class="slider-position' + (i === 0 ? ' active-indicator' : '') + '" data-position="' + i + '"></li>')
+                i++;
+            });
+
+            $this.element.addClass('visible');
+
             this.initEvents();
         },
 
@@ -51,10 +65,10 @@ window.Hammer = Hammer.default;
                 $this.resize();
             });
 
-            this.autoSlideDelay = 4; // automatic slideshow delay
+            this.autoSlideDuration = 8; // automatic slideshow delay
             this.slideInterval = window.setTimeout(function () {
                 $this.nextSlide();
-            }, this.autoSlideDelay * 1000);
+            }, this.autoSlideDuration * 1000);
 
             this.resize();
             this.initSwipeEvent();
@@ -87,7 +101,10 @@ window.Hammer = Hammer.default;
                 let width = $(this).width(), // --> container width (clip container)
                     height = $(this).height(); // --> container height (clip container)
 
-                TweenMax.set($(this), {clip: $this.init + width + 'px ' + height + $this.final, ease: Power3.easeOut}); // on resize apply new width/height to clip container
+                TweenMax.set($(this), {
+                    clip: $this.initRect + width + 'px ' + height + $this.finalRect,
+                    ease: Power3.easeOut
+                }); // on resize apply new width/height to clip container
             });
         },
 
@@ -116,13 +133,13 @@ window.Hammer = Hammer.default;
                 if ($this.automode) {
                     $this.slideInterval = setTimeout(function () {
                         $this.nextSlide();
-                    }, $this.autoSlideDelay * 1000);
+                    }, $this.autoSlideDuration * 1000);
                 }
 
                 $this.enableArrows(); // when animation is finished we reactivate click event
                 $this.automaticSlideshow();
                 TweenMax.set($this.element.find('.slide-img'), {
-                    clip: $this.init + $this.width + 'px ' + $this.height + $this.final,
+                    clip: $this.initRect + $this.width + 'px ' + $this.height + $this.finalRect,
                     ease: Power3.easeOut
                 });
 
@@ -130,7 +147,7 @@ window.Hammer = Hammer.default;
 
             if ($(window).outerWidth() > 768) {
                 TweenMax.set($this.element.find('.slide-img'), {
-                    clip: $this.init + $this.width + 'px ' + $this.height + $this.final,
+                    clip: $this.initRect + $this.width + 'px ' + $this.height + $this.finalRect,
                     ease: Power3.easeOut
                 });
 
@@ -144,7 +161,7 @@ window.Hammer = Hammer.default;
                     ease: Power1.easeOut
                 });
                 tl.to($this.currentContainerImg, 2 * $this.Delay, {
-                    clip: $this.init + (direction) * -1 * $this.imgWidth + 'px,' + $this.height + 'px,' + (direction) * -1 * $this.imgWidth + 'px',
+                    clip: $this.initRect + (direction) * -1 * $this.imgWidth + 'px,' + $this.height + 'px,' + (direction) * -1 * $this.imgWidth + 'px',
                     ease: Power2.easeInOut
                 }, "-=" + 0.8 * $this.Delay);
 
@@ -251,8 +268,8 @@ window.Hammer = Hammer.default;
             });
         },
 
-        endAutomode:function(){
-            this.automode=false;
+        endAutomode: function () {
+            this.automode = false;
             clearTimeout(this.slideInterval);
         },
 
index 356a1f846089a5b3a81d7b061646bc190ee975b0..5f3f5db08f644522d767b34f3a4f65c6434e4d3b 100644 (file)
   $verylightgrey = #E7E9F3
   $controlSize = 60px;
 
+  opacity 0;
+  transition opacity 250ms
+
+  &.visible
+    opacity: 1;
+
   .column-wrapper.hide
     display none
 
@@ -73,6 +79,7 @@
     @media (max-width 769px)
       left: 50%
       transform: translateX(-50%)
+
     ul
       display flex
       align-items: center;
index 78e3780e90ce70d5e7be919f9a3cbf93ca5fd1d9..85723bcf3bc87fc050edf8ee765adb564af97eb8 100644 (file)
@@ -19,8 +19,7 @@
             </div>
             <div id="pmiSlider" class="slider relative">
                 @foreach($page->get('slideshow') as $i=>$slide)
-                    <div data-slide="{{$i+1}}"
-                         class="column-wrapper absolute slide @if($i==0) active @else hide @endif">
+                    <div class="column-wrapper absolute slide hide">
 
                         <column class="slide-content slide-txt pt-2v pr-1v pb-2v">
                             <div class="mobile-bg"
@@ -49,9 +48,6 @@
                 @endforeach
                 <div class="slider-indicator">
                     <ul class="pl-2v">
-                        @foreach($page->get('slideshow') as $i=>$slide)
-                            <li class="slider-position @if($i==0) active-indicator @endif" data-position="{{$i}}"></li>
-                        @endforeach
                     </ul>
                 </div>
             </div>
@@ -65,7 +61,7 @@
     <full-width class="bg-grey-100">
         <content>
 
-            <text-block class="mb-2v" title="Nos Produits"/>
+            <text-block class="mb-2v" :title="__('Nos Produits')"/>
 
             <columns>
                 <column>