From b85a6c67df9d932ab2c20e798e62894aa4cebe35 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 16 Jul 2015 12:52:36 +0300 Subject: [PATCH 1/7] added support for events: setPosition, beforeChange --- dist/slick.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dist/slick.js b/dist/slick.js index e9da126..08d3b12 100644 --- a/dist/slick.js +++ b/dist/slick.js @@ -124,6 +124,16 @@ angular.module('slick', []).directive('slick', [ return sl.slideHandler(currentIndex); } }); + slider.on('setPosition', function (sl) { + if (attrs.onSetPosition) { + scope.onSetPosition(); + } + }); + slider.on('beforeChange', function (sl) { + if (attrs.onBeforeChange) { + scope.onBeforeChange(); + } + }); slider.on('afterChange', function (event, slick, currentSlide, nextSlide) { if (scope.onAfterChange) { scope.onAfterChange(); From 891a8480b225e3e29c3a01160e79a6b7b4636756 Mon Sep 17 00:00:00 2001 From: Gal Ziv Date: Thu, 16 Jul 2015 13:16:09 +0300 Subject: [PATCH 2/7] added support for events: setPosition, beforeChange --- dist/slick.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/slick.js b/dist/slick.js index 08d3b12..95bf25e 100644 --- a/dist/slick.js +++ b/dist/slick.js @@ -116,27 +116,27 @@ angular.module('slick', []).directive('slick', [ prevArrow: scope.prevArrow ? $(scope.prevArrow) : void 0, nextArrow: scope.nextArrow ? $(scope.nextArrow) : void 0 }); - slider.on('init', function (sl) { + slider.on('init', function (event, slick) { if (attrs.onInit) { - scope.onInit(); + scope.onInit(event, slick); } if (currentIndex != null) { return sl.slideHandler(currentIndex); } }); - slider.on('setPosition', function (sl) { + slider.on('setPosition', function (event, slick) { if (attrs.onSetPosition) { - scope.onSetPosition(); + scope.onSetPosition(event, slick); } }); - slider.on('beforeChange', function (sl) { + slider.on('beforeChange', function (event, slick, currentSlide, nextSlide) { if (attrs.onBeforeChange) { - scope.onBeforeChange(); + scope.onBeforeChange(event, slick, currentSlide, nextSlide); } }); - slider.on('afterChange', function (event, slick, currentSlide, nextSlide) { + slider.on('afterChange', function (event, slick, currentSlide) { if (scope.onAfterChange) { - scope.onAfterChange(); + scope.onAfterChange(event, slick, currentSlide); } if (currentIndex != null) { return scope.$apply(function () { From 2fec79e0572850b1307137903a3a1f0948c538f5 Mon Sep 17 00:00:00 2001 From: Gal Ziv Date: Thu, 16 Jul 2015 13:36:07 +0300 Subject: [PATCH 3/7] added support for edgeFriction --- dist/slick.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dist/slick.js b/dist/slick.js index 95bf25e..145b402 100644 --- a/dist/slick.js +++ b/dist/slick.js @@ -23,6 +23,7 @@ angular.module('slick', []).directive('slick', [ dots: '@', draggable: '@', easing: '@', + edgeFriction: '@', fade: '@', focusOnSelect: '@', infinite: '@', @@ -91,6 +92,7 @@ angular.module('slick', []).directive('slick', [ dots: scope.dots === 'true', draggable: scope.draggable !== 'false', easing: scope.easing || 'linear', + edgeFriction: scope.edgeFriction || 0.15, // default value as per slick's website fade: scope.fade === 'true', focusOnSelect: scope.focusOnSelect === 'true', infinite: scope.infinite !== 'false', From 24dcf8b1caff5f445dd9ffbe3ed613e1916215a1 Mon Sep 17 00:00:00 2001 From: Gal Ziv Date: Thu, 16 Jul 2015 15:20:50 +0300 Subject: [PATCH 4/7] fixed currentIndex binding --- dist/slick.js | 335 +++++++++++++++++++++++++------------------------- 1 file changed, 168 insertions(+), 167 deletions(-) diff --git a/dist/slick.js b/dist/slick.js index 145b402..32ea5dc 100644 --- a/dist/slick.js +++ b/dist/slick.js @@ -2,173 +2,174 @@ angular.module('slick', []).directive('slick', [ '$timeout', function ($timeout) { - return { - restrict: 'AEC', - scope: { - initOnload: '@', - data: '=', - currentIndex: '=', - accessibility: '@', - adaptiveHeight: '@', - arrows: '@', - asNavFor: '@', - appendArrows: '@', - appendDots: '@', - autoplay: '@', - autoplaySpeed: '@', - centerMode: '@', - centerPadding: '@', - cssEase: '@', - customPaging: '&', - dots: '@', - draggable: '@', - easing: '@', - edgeFriction: '@', - fade: '@', - focusOnSelect: '@', - infinite: '@', - initialSlide: '@', - lazyLoad: '@', - onBeforeChange: '&', - onAfterChange: '&', - onInit: '&', - onReInit: '&', - onSetPosition: '&', - pauseOnHover: '@', - pauseOnDotsHover: '@', - responsive: '=', - rtl: '@', - slide: '@', - slidesToShow: '@', - slidesToScroll: '@', - speed: '@', - swipe: '@', - swipeToSlide: '@', - touchMove: '@', - touchThreshold: '@', - useCSS: '@', - variableWidth: '@', - vertical: '@', - prevArrow: '@', - nextArrow: '@' - }, - link: function (scope, element, attrs) { - var destroySlick, initializeSlick, isInitialized; - destroySlick = function () { - return $timeout(function () { - var slider; - slider = $(element); - slider.slick('unslick'); - slider.find('.slick-list').remove(); - return slider; - }); - }; - initializeSlick = function () { - return $timeout(function () { - var currentIndex, customPaging, slider; - slider = $(element); - if (scope.currentIndex != null) { - currentIndex = scope.currentIndex; - } - customPaging = function (slick, index) { - return scope.customPaging({ - slick: slick, - index: index - }); - }; - slider.slick({ - accessibility: scope.accessibility !== 'false', - adaptiveHeight: scope.adaptiveHeight === 'true', - arrows: scope.arrows !== 'false', - asNavFor: scope.asNavFor ? scope.asNavFor : void 0, - appendArrows: scope.appendArrows ? $(scope.appendArrows) : $(element), - appendDots: scope.appendDots ? $(scope.appendDots) : $(element), - autoplay: scope.autoplay === 'true', - autoplaySpeed: scope.autoplaySpeed != null ? parseInt(scope.autoplaySpeed, 10) : 3000, - centerMode: scope.centerMode === 'true', - centerPadding: scope.centerPadding || '50px', - cssEase: scope.cssEase || 'ease', - customPaging: attrs.customPaging ? customPaging : void 0, - dots: scope.dots === 'true', - draggable: scope.draggable !== 'false', - easing: scope.easing || 'linear', - edgeFriction: scope.edgeFriction || 0.15, // default value as per slick's website - fade: scope.fade === 'true', - focusOnSelect: scope.focusOnSelect === 'true', - infinite: scope.infinite !== 'false', - initialSlide: scope.initialSlide || 0, - lazyLoad: scope.lazyLoad || 'ondemand', - beforeChange: attrs.onBeforeChange ? scope.onBeforeChange : void 0, - onReInit: attrs.onReInit ? scope.onReInit : void 0, - onSetPosition: attrs.onSetPosition ? scope.onSetPosition : void 0, - pauseOnHover: scope.pauseOnHover !== 'false', - responsive: scope.responsive || void 0, - rtl: scope.rtl === 'true', - slide: scope.slide || 'div', - slidesToShow: scope.slidesToShow != null ? parseInt(scope.slidesToShow, 10) : 1, - slidesToScroll: scope.slidesToScroll != null ? parseInt(scope.slidesToScroll, 10) : 1, - speed: scope.speed != null ? parseInt(scope.speed, 10) : 300, - swipe: scope.swipe !== 'false', - swipeToSlide: scope.swipeToSlide === 'true', - touchMove: scope.touchMove !== 'false', - touchThreshold: scope.touchThreshold ? parseInt(scope.touchThreshold, 10) : 5, - useCSS: scope.useCSS !== 'false', - variableWidth: scope.variableWidth === 'true', - vertical: scope.vertical === 'true', - prevArrow: scope.prevArrow ? $(scope.prevArrow) : void 0, - nextArrow: scope.nextArrow ? $(scope.nextArrow) : void 0 - }); - slider.on('init', function (event, slick) { - if (attrs.onInit) { - scope.onInit(event, slick); + return { + restrict: 'AEC', + scope: { + initOnload: '@', + data: '=?', + currentIndex: '=?', + accessibility: '@', + adaptiveHeight: '@', + arrows: '@', + asNavFor: '@', + appendArrows: '@', + appendDots: '@', + autoplay: '@', + autoplaySpeed: '@', + centerMode: '@', + centerPadding: '@', + cssEase: '@', + customPaging: '&', + dots: '@', + draggable: '@', + easing: '@', + edgeFriction: '@', + fade: '@', + focusOnSelect: '@', + infinite: '@', + initialSlide: '@', + lazyLoad: '@', + onBeforeChange: '&', + onAfterChange: '&', + onInit: '&', + onReInit: '&', + onSetPosition: '&', + pauseOnHover: '@', + pauseOnDotsHover: '@', + responsive: '=?', + rtl: '@', + slide: '@', + slidesToShow: '@', + slidesToScroll: '@', + speed: '@', + swipe: '@', + swipeToSlide: '@', + touchMove: '@', + touchThreshold: '@', + useCSS: '@', + variableWidth: '@', + vertical: '@', + prevArrow: '@', + nextArrow: '@' + }, + link: function (scope, element, attrs) { + var destroySlick, initializeSlick, isInitialized; + destroySlick = function () { + return $timeout(function () { + var slider; + slider = $(element); + slider.slick('unslick'); + slider.find('.slick-list').remove(); + return slider; + }); + }; + initializeSlick = function () { + return $timeout(function () { + var currentIndex, customPaging, slider; + slider = $(element); + scope.currentIndex = scope.initialSlide || scope.currentIndex; + if (scope.currentIndex != null) { + currentIndex = scope.currentIndex; + } + customPaging = function (slick, index) { + return scope.customPaging({ + slick: slick, + index: index + }); + }; + slider.slick({ + accessibility: scope.accessibility !== 'false', + adaptiveHeight: scope.adaptiveHeight === 'true', + arrows: scope.arrows !== 'false', + asNavFor: scope.asNavFor ? scope.asNavFor : void 0, + appendArrows: scope.appendArrows ? $(scope.appendArrows) : $(element), + appendDots: scope.appendDots ? $(scope.appendDots) : $(element), + autoplay: scope.autoplay === 'true', + autoplaySpeed: scope.autoplaySpeed != null ? parseInt(scope.autoplaySpeed, 10) : 3000, + centerMode: scope.centerMode === 'true', + centerPadding: scope.centerPadding || '50px', + cssEase: scope.cssEase || 'ease', + customPaging: attrs.customPaging ? customPaging : void 0, + dots: scope.dots === 'true', + draggable: scope.draggable !== 'false', + easing: scope.easing || 'linear', + edgeFriction: scope.edgeFriction || 0.15, // default value as per slick's website + fade: scope.fade === 'true', + focusOnSelect: scope.focusOnSelect === 'true', + infinite: scope.infinite !== 'false', + initialSlide: scope.initialSlide || 0, + lazyLoad: scope.lazyLoad || 'ondemand', + beforeChange: attrs.onBeforeChange ? scope.onBeforeChange : void 0, + onReInit: attrs.onReInit ? scope.onReInit : void 0, + onSetPosition: attrs.onSetPosition ? scope.onSetPosition : void 0, + pauseOnHover: scope.pauseOnHover !== 'false', + responsive: scope.responsive || void 0, + rtl: scope.rtl === 'true', + slide: scope.slide || 'div', + slidesToShow: scope.slidesToShow != null ? parseInt(scope.slidesToShow, 10) : 1, + slidesToScroll: scope.slidesToScroll != null ? parseInt(scope.slidesToScroll, 10) : 1, + speed: scope.speed != null ? parseInt(scope.speed, 10) : 300, + swipe: scope.swipe !== 'false', + swipeToSlide: scope.swipeToSlide === 'true', + touchMove: scope.touchMove !== 'false', + touchThreshold: scope.touchThreshold ? parseInt(scope.touchThreshold, 10) : 5, + useCSS: scope.useCSS !== 'false', + variableWidth: scope.variableWidth === 'true', + vertical: scope.vertical === 'true', + prevArrow: scope.prevArrow ? $(scope.prevArrow) : void 0, + nextArrow: scope.nextArrow ? $(scope.nextArrow) : void 0 + }); + slider.on('init', function (event, slick) { + if (attrs.onInit) { + scope.onInit(event, slick); + } + if (currentIndex != null) { + return sl.slideHandler(currentIndex); + } + }); + slider.on('setPosition', function (event, slick) { + if (attrs.onSetPosition) { + scope.onSetPosition(event, slick); + } + }); + slider.on('beforeChange', function (event, slick, currentSlide, nextSlide) { + if (attrs.onBeforeChange) { + scope.onBeforeChange(event, slick, currentSlide, nextSlide); + } + }); + slider.on('afterChange', function (event, slick, currentSlide) { + if (scope.onAfterChange) { + scope.onAfterChange(event, slick, currentSlide); + } + if (scope.currentIndex != null) { + return scope.$apply(function () { + currentIndex = currentSlide; + return scope.currentIndex = currentSlide; + }); + } + }); + return scope.$watch('currentIndex', function (newVal, oldVal) { + if (currentIndex != null && newVal != null && newVal !== currentIndex) { + return slider.slick('slickGoTo', newVal); + } + }); + }); + }; + if (scope.initOnload) { + isInitialized = false; + return scope.$watch('data', function (newVal, oldVal) { + if (newVal != null) { + if (isInitialized) { + destroySlick(); + } + initializeSlick(); + return isInitialized = true; + } + }); + } else { + return initializeSlick(); } - if (currentIndex != null) { - return sl.slideHandler(currentIndex); - } - }); - slider.on('setPosition', function (event, slick) { - if (attrs.onSetPosition) { - scope.onSetPosition(event, slick); - } - }); - slider.on('beforeChange', function (event, slick, currentSlide, nextSlide) { - if (attrs.onBeforeChange) { - scope.onBeforeChange(event, slick, currentSlide, nextSlide); - } - }); - slider.on('afterChange', function (event, slick, currentSlide) { - if (scope.onAfterChange) { - scope.onAfterChange(event, slick, currentSlide); - } - if (currentIndex != null) { - return scope.$apply(function () { - currentIndex = currentSlide; - return scope.currentIndex = currentSlide; - }); - } - }); - return scope.$watch('currentIndex', function (newVal, oldVal) { - if (currentIndex != null && newVal != null && newVal !== currentIndex) { - return slider.slick('slickGoTo', newVal); - } - }); - }); - }; - if (scope.initOnload) { - isInitialized = false; - return scope.$watch('data', function (newVal, oldVal) { - if (newVal != null) { - if (isInitialized) { - destroySlick(); - } - initializeSlick(); - return isInitialized = true; - } - }); - } else { - return initializeSlick(); - } - } - }; + } + }; } ]); \ No newline at end of file From f54d19fcabfe24e321d7334e80d34f1c514697e1 Mon Sep 17 00:00:00 2001 From: Gal Ziv Date: Thu, 16 Jul 2015 17:13:44 +0300 Subject: [PATCH 5/7] create new bower package name --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 9e24782..d46d9a0 100644 --- a/bower.json +++ b/bower.json @@ -1,5 +1,5 @@ { - "name": "angular-slick", + "name": "angular-slick-extended", "version": "0.2.1", "main": "dist/slick.js", "ignore": [ From 4ea609abdc2ab1550644c8ce70005b0dd2e830bf Mon Sep 17 00:00:00 2001 From: Gal Ziv Date: Thu, 16 Jul 2015 17:14:17 +0300 Subject: [PATCH 6/7] Update bower.json --- bower.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index d46d9a0..ca37516 100644 --- a/bower.json +++ b/bower.json @@ -20,9 +20,9 @@ ], "dependencies": { "angular": "~1.3.0", - "slick-carousel": "~1.4.1" + "slick-carousel": "1.5.6" }, "author": { - "name": "Vasyl Stanislavchuk" + "name": "Gal Ziv" } } From 67f448e0458dc7b877e0ec8fd9771b85a50fe6e6 Mon Sep 17 00:00:00 2001 From: Gal Ziv Date: Thu, 16 Jul 2015 17:15:46 +0300 Subject: [PATCH 7/7] Update bower.json --- bower.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index ca37516..6ee6e0c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { - "name": "angular-slick-extended", - "version": "0.2.1", + "name": "slick-angular", + "version": "0.3", "main": "dist/slick.js", "ignore": [ "app",