From 82b8ca289e02238d8e5be64b26d6b1ecd8ea9332 Mon Sep 17 00:00:00 2001 From: cohenudi Date: Sun, 3 May 2015 09:46:25 +0300 Subject: [PATCH] Move the call to onAfterChange Calling it only after changing the currentIndex on the scope thus saving the users setting up a watch on that property. --- app/scripts/app.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/scripts/app.coffee b/app/scripts/app.coffee index f10dd50..67e8388 100644 --- a/app/scripts/app.coffee +++ b/app/scripts/app.coffee @@ -115,14 +115,15 @@ angular.module('slick', []) sl.slideHandler(currentIndex) slider.on 'afterChange', (event, slick, currentSlide, nextSlide) -> - scope.onAfterChange() if scope.onAfterChange - if currentIndex? scope.$apply(-> currentIndex = currentSlide scope.currentIndex = currentSlide ) + # call the onAfterChange after changing the scope + scope.onAfterChange() if scope.onAfterChange + scope.$watch("currentIndex", (newVal, oldVal) -> if currentIndex? and newVal? and newVal != currentIndex slider.slick('slickGoTo', newVal)