devmark / angular-slick-carousel

Angular directive for slick-carousel
http://devmark.github.io/angular-slick-carousel/
MIT License
353 stars 125 forks source link

How to get current slide index? #105

Open supermarioim opened 7 years ago

supermarioim commented 7 years ago

As I can see there is method slickCurrentSlide in original slick methods, but it's not ported...

kukac7 commented 7 years ago

@supermarioim https://github.com/devmark/angular-slick-carousel#faq

Q: After change data, could i keep the current slide index? A: For this directive, this will destroy and init slick when updating data. You could get current index by event. example:

    $scope.currentIndex = 0;
    $scope.slickConfig = {
        event: {
            afterChange: function (event, slick, currentSlide, nextSlide) {
              $scope.currentIndex = currentSlide; // save current index each time
            }
            init: function (event, slick) {
              slick.slickGoTo($scope.currentIndex); // slide to correct index when init
            }
        }
    };

what's your problem with that?