The Old County
The Old County

Reputation: 99

Slick carousel with parallax elements

I've tried to create a bespoke parallax when the user swipes left/right, using the slick carousel.

Although need to enhance it further so the unseen images reset.

$(this).find(".parallaxback img:visible").animate({
   left: increment+"=15"
}, 700, function() {
   // Animation complete.
});

Tried to use the : visible selector, but I don't feel its having an effect.

Upvotes: 3

Views: 8098

Answers (1)

user1171884
user1171884

Reputation:

this an example with parallax animating in reverse to the movement. Although I'm not sure how you would set the parallax during a drag/during the swipe movement -- instead of after/before its finished the swipe.

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

var parallaxAnimate = function(el, currentSlide, nextSlide){
    console.log("parallax animate");

    var increment = "+";

     if (currentSlide > nextSlide) {
         increment = "-";
     }

     $(el).find(".parallaxback img:visible").animate({
         left: increment + "=15"
     }, 400, function () {
         // Animation complete.
     });       
};


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

Upvotes: 1

Related Questions