devmark / angular-slick-carousel

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

event call on update settings duplicated #78

Open cdelhomme opened 8 years ago

cdelhomme commented 8 years ago

in code , there is a watch on settings changes. when this change is made , the destroyandInit function is call, in this function the init is call . in the init function you have on calling to initiate the event listener.

each time setting change its add one listener to the event .

to prevent this you have to : 1 - name the event with a namespace , 2 - make a call to off before on

example : slickness.on('swipe', function (event, slick, direction) { $timeout(function () { scope.$apply(function () { options.event.swipe(event, slick, direction); }); }); }); becomes : slickness.off('swipe.slickCarousel').on('swipe.slickCarousel', function (event, slick, direction) { $timeout(function () { scope.$apply(function () { options.event.swipe(event, slick, direction); }); }); });

devmark commented 8 years ago

Thanks for report. Will take a look soon!