简体   繁体   中英

Slick Carousel dragging event

I'm working on a parallax slick carousel. I am trying to find out how you can go about activating the parallax during a drag. I think its activating during a slide when you click on the arrows.

http://jsfiddle.net/ayve1nmf/27/

// On before slide change
 $('.data').on('beforeChange', function (event, slick, currentSlide, nextSlide) {
    console.log("beforeChange");
     //console.log(nextSlide);
     parallaxAnimate(this, currentSlide, nextSlide);
 });

You'll need to apply your own dragstart or dragging event(s). It's pretty easy, the basics of it would be something like this

// Event to initiate drag, include touchstart events
$('.data').on('mousedown', function(e){

 // Drag start logic
 // ...

 // Event to end drag, may want to include touchend events
 $(this).one('mouseup', function(e){

  $(this).off('mousemove');
  // Drag stop logic
  // ...

 }).on('mousemove', function(e){

  // Logic for dragging, can get mouse position
  // will probably want to throttle
  // possibly include touchmove events also
  console.log(e.pageX);

 });

});

http://jsfiddle.net/ayve1nmf/172/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM