init = 'rect(0px ',
final = 'px 0px)';
+let container = document.querySelector('.slider');
+let listener = SwipeListener(container);
+
resize();
$(window).on('orientationchange',function () {
// // RESIZE
function resize() {
+ // if ($(window).width() > 769) {
+ // listener.off();
+ // }
+
$('.img-slider').each(function () {
let width = $('.slide-img').eq(index).width(),
height = $('.slide-img').eq(index).height();
height = $(this).height(); // --> container height (clip container)
TweenMax.set($(this),{clip:init + width +'px '+ height+ final, ease: Power3.easeOut}); // on resize apply new width/height to clip container
-
- console.log('container --> '+ width,height);
});
}
currentSlideIndex.removeClass('active').eq(index);
enableArrows(); // when animation is finished we reactivate click event
-
TweenMax.set($('.slide-img'),{clip:init + width +'px '+ height+ final, ease: Power3.easeOut});
- // isRunning = false;
};
console.log(nextindex, direction);
TweenMax.set($('.slide-img'),{clip:init + width +'px '+ height+ final, ease: Power3.easeOut});
+ // TODO : remove negative delay
// negative delay slow the end of this timeline
let tl = new TimelineMax({onComplete: finishAnimation});
// console.log(tl.duration()); // timeline duration
}
-//
-// arrowNavigation();
-//
-// function arrowNavigation() {
-// $('.arrow').on('click', function () {
-// resize();
-// if ($(this).is('.next')) {
-// direction = 1;
-// }
-// else {
-// direction = -1;
-// }
-// let nextindex = (index + direction + slideLength) % slideLength;
-// GotoSlide(nextindex, direction);
-// });
-// }
-
function nextSlide() {
let direction = 1;
$('.arrow.prev').off();
}
- enableArrows();
\ No newline at end of file
+ enableArrows();
+
+// TODO : 1 --> change the frequency of the swipe: we can swipe when the animation Timeline is over
+// TODO : 2 --> Disable swipe when screen size >768px
+
+// TODO : BUG --> si on swipe (next, prev, next) on ne voit plus l'image
+function SwipeContent(){
+ container.addEventListener('swipe', function (e) {
+ let directions = e.detail.directions;
+ let x = e.detail.x;
+ let y = e.detail.y;
+
+ if (directions.left) {
+ prevSlide();
+ }
+
+ if (directions.right) {
+ nextSlide();
+ }
+ });
+}
+SwipeContent();
+
+// if ($(window).width() > 769) {
+// listener.off();
+// }
\ No newline at end of file