diff --git a/app/scripts/app.coffee b/app/scripts/app.coffee index f10dd50..ef35bfb 100644 --- a/app/scripts/app.coffee +++ b/app/scripts/app.coffee @@ -27,6 +27,7 @@ angular.module('slick', []) infinite: "@" initialSlide: "@" lazyLoad: "@" + mobileFirst: "@" onBeforeChange: "&" onAfterChange: "&" onInit: "&" @@ -72,8 +73,8 @@ angular.module('slick', []) adaptiveHeight: scope.adaptiveHeight is "true" arrows: scope.arrows isnt "false" asNavFor: if scope.asNavFor then scope.asNavFor else undefined - appendArrows: if scope.appendArrows then $(scope.appendArrows) else $(element) - appendDots: if scope.appendDots then $(scope.appendDots) else $(element) + appendArrows: if scope.appendArrows then angular.element(scope.appendArrows) else angular.element(element) + appendDots: if scope.appendDots then angular.element(scope.appendDots) else angular.element(element) autoplay: scope.autoplay is "true" autoplaySpeed: if scope.autoplaySpeed? then parseInt(scope.autoplaySpeed, 10) else 3000 centerMode: scope.centerMode is "true" @@ -85,8 +86,9 @@ angular.module('slick', []) easing: scope.easing or "linear" fade: scope.fade is "true" focusOnSelect: scope.focusOnSelect is "true" + mobileFirst: scope.mobileFirst is "true" infinite: scope.infinite isnt "false" - initialSlide:scope.initialSlide or 0 + initialSlide: if scope.initialSlide? then parseInt(scope.initialSlide, 10) else 0 lazyLoad: scope.lazyLoad or "ondemand" beforeChange: if attrs.onBeforeChange then scope.onBeforeChange else undefined onReInit: if attrs.onReInit then scope.onReInit else undefined @@ -105,8 +107,8 @@ angular.module('slick', []) useCSS: scope.useCSS isnt "false" variableWidth: scope.variableWidth is "true" vertical: scope.vertical is "true" - prevArrow: if scope.prevArrow then $(scope.prevArrow) else undefined - nextArrow: if scope.nextArrow then $(scope.nextArrow) else undefined + prevArrow: if scope.prevArrow then angular.element(scope.prevArrow) else undefined + nextArrow: if scope.nextArrow then angular.element(scope.nextArrow) else undefined slider.on 'init', (sl) -> @@ -114,6 +116,15 @@ angular.module('slick', []) if currentIndex? sl.slideHandler(currentIndex) + slider.on 'reInit', (sl) -> + scope.onReInit() if attrs.onReInit + + slider.on 'setPosition', (sl) -> + scope.onSetPosition() if attrs.onSetPosition + + slider.on 'swipe', (sl) -> + scope.onSwipe() if attrs.onSwipe + slider.on 'afterChange', (event, slick, currentSlide, nextSlide) -> scope.onAfterChange() if scope.onAfterChange @@ -123,6 +134,18 @@ angular.module('slick', []) scope.currentIndex = currentSlide ) + slider.on 'beforeChange', (sl) -> + scope.onBeforeChange() if attrs.onBeforeChange + + slider.on 'breakpoint', (sl) -> + scope.onBreakpoint() if attrs.onBreakpoint + + slider.on 'destroy', (sl) -> + scope.onDestroy() if attrs.onDestroy + + slider.on 'edge', (sl) -> + scope.onEdge() if attrs.onEdge + scope.$watch("currentIndex", (newVal, oldVal) -> if currentIndex? and newVal? and newVal != currentIndex slider.slick('slickGoTo', newVal) diff --git a/bower.json b/bower.json index 9e24782..e6eee89 100644 --- a/bower.json +++ b/bower.json @@ -19,8 +19,8 @@ "carousel" ], "dependencies": { - "angular": "~1.3.0", - "slick-carousel": "~1.4.1" + "angular": ">=1.3.0", + "slick-carousel": "~1.5.5" }, "author": { "name": "Vasyl Stanislavchuk" diff --git a/dist/slick.js b/dist/slick.js index e9da126..13dfe49 100644 --- a/dist/slick.js +++ b/dist/slick.js @@ -28,6 +28,7 @@ angular.module('slick', []).directive('slick', [ infinite: '@', initialSlide: '@', lazyLoad: '@', + mobileFirst: '@', onBeforeChange: '&', onAfterChange: '&', onInit: '&', @@ -80,8 +81,8 @@ angular.module('slick', []).directive('slick', [ 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), + appendArrows: scope.appendArrows ? angular.element(scope.appendArrows) : angular.element(element), + appendDots: scope.appendDots ? angular.element(scope.appendDots) : angular.element(element), autoplay: scope.autoplay === 'true', autoplaySpeed: scope.autoplaySpeed != null ? parseInt(scope.autoplaySpeed, 10) : 3000, centerMode: scope.centerMode === 'true', @@ -93,8 +94,9 @@ angular.module('slick', []).directive('slick', [ easing: scope.easing || 'linear', fade: scope.fade === 'true', focusOnSelect: scope.focusOnSelect === 'true', + mobileFirst: scope.mobileFirst === 'true', infinite: scope.infinite !== 'false', - initialSlide: scope.initialSlide || 0, + initialSlide: scope.initialSlide != null ? parseInt(scope.initialSlide, 10) : 0, lazyLoad: scope.lazyLoad || 'ondemand', beforeChange: attrs.onBeforeChange ? scope.onBeforeChange : void 0, onReInit: attrs.onReInit ? scope.onReInit : void 0, @@ -113,8 +115,8 @@ angular.module('slick', []).directive('slick', [ 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 + prevArrow: scope.prevArrow ? angular.element(scope.prevArrow) : void 0, + nextArrow: scope.nextArrow ? angular.element(scope.nextArrow) : void 0 }); slider.on('init', function (sl) { if (attrs.onInit) { @@ -124,6 +126,21 @@ angular.module('slick', []).directive('slick', [ return sl.slideHandler(currentIndex); } }); + slider.on('reInit', function (sl) { + if (attrs.onReInit) { + return scope.onReInit(); + } + }); + slider.on('setPosition', function (sl) { + if (attrs.onSetPosition) { + return scope.onSetPosition(); + } + }); + slider.on('swipe', function (sl) { + if (attrs.onSwipe) { + return scope.onSwipe(); + } + }); slider.on('afterChange', function (event, slick, currentSlide, nextSlide) { if (scope.onAfterChange) { scope.onAfterChange(); @@ -135,6 +152,26 @@ angular.module('slick', []).directive('slick', [ }); } }); + slider.on('beforeChange', function (sl) { + if (attrs.onBeforeChange) { + return scope.onBeforeChange(); + } + }); + slider.on('breakpoint', function (sl) { + if (attrs.onBreakpoint) { + return scope.onBreakpoint(); + } + }); + slider.on('destroy', function (sl) { + if (attrs.onDestroy) { + return scope.onDestroy(); + } + }); + slider.on('edge', function (sl) { + if (attrs.onEdge) { + return scope.onEdge(); + } + }); return scope.$watch('currentIndex', function (newVal, oldVal) { if (currentIndex != null && newVal != null && newVal !== currentIndex) { return slider.slick('slickGoTo', newVal); @@ -159,4 +196,4 @@ angular.module('slick', []).directive('slick', [ } }; } -]); \ No newline at end of file +]); diff --git a/dist/slick.min.js b/dist/slick.min.js index 0b74254..a8bfc1f 100644 --- a/dist/slick.min.js +++ b/dist/slick.min.js @@ -1,2 +1,2 @@ -/*! angular-slick v0.2.0 */ -"use strict";angular.module("slick",[]).directive("slick",["$timeout",function(a){return{restrict:"AEC",scope:{initOnload:"@",data:"=",currentIndex:"=",accessibility:"@",adaptiveHeight:"@",arrows:"@",asNavFor:"@",appendArrows:"@",appendDots:"@",autoplay:"@",autoplaySpeed:"@",centerMode:"@",centerPadding:"@",cssEase:"@",customPaging:"&",dots:"@",draggable:"@",easing:"@",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(b,c,d){var e,f,g;return e=function(){return a(function(){var a;return a=$(c),a.slick("unslick"),a.find(".slick-list").remove(),a})},f=function(){return a(function(){var a,e,f;return f=$(c),null!=b.currentIndex&&(a=b.currentIndex),e=function(a,c){return b.customPaging({slick:a,index:c})},f.slick({accessibility:"false"!==b.accessibility,adaptiveHeight:"true"===b.adaptiveHeight,arrows:"false"!==b.arrows,asNavFor:b.asNavFor?b.asNavFor:void 0,appendArrows:$(b.appendArrows?b.appendArrows:c),appendDots:$(b.appendDots?b.appendDots:c),autoplay:"true"===b.autoplay,autoplaySpeed:null!=b.autoplaySpeed?parseInt(b.autoplaySpeed,10):3e3,centerMode:"true"===b.centerMode,centerPadding:b.centerPadding||"50px",cssEase:b.cssEase||"ease",customPaging:d.customPaging?e:void 0,dots:"true"===b.dots,draggable:"false"!==b.draggable,easing:b.easing||"linear",fade:"true"===b.fade,focusOnSelect:"true"===b.focusOnSelect,infinite:"false"!==b.infinite,initialSlide:b.initialSlide||0,lazyLoad:b.lazyLoad||"ondemand",beforeChange:d.onBeforeChange?b.onBeforeChange:void 0,onReInit:d.onReInit?b.onReInit:void 0,onSetPosition:d.onSetPosition?b.onSetPosition:void 0,pauseOnHover:"false"!==b.pauseOnHover,responsive:b.responsive||void 0,rtl:"true"===b.rtl,slide:b.slide||"div",slidesToShow:null!=b.slidesToShow?parseInt(b.slidesToShow,10):1,slidesToScroll:null!=b.slidesToScroll?parseInt(b.slidesToScroll,10):1,speed:null!=b.speed?parseInt(b.speed,10):300,swipe:"false"!==b.swipe,swipeToSlide:"true"===b.swipeToSlide,touchMove:"false"!==b.touchMove,touchThreshold:b.touchThreshold?parseInt(b.touchThreshold,10):5,useCSS:"false"!==b.useCSS,variableWidth:"true"===b.variableWidth,vertical:"true"===b.vertical,prevArrow:b.prevArrow?$(b.prevArrow):void 0,nextArrow:b.nextArrow?$(b.nextArrow):void 0}),f.on("init",function(c){return d.onInit&&b.onInit(),null!=a?c.slideHandler(a):void 0}),f.on("afterChange",function(c,d,e){return b.onAfterChange&&b.onAfterChange(),null!=a?b.$apply(function(){return a=e,b.currentIndex=e}):void 0}),b.$watch("currentIndex",function(b){return null!=a&&null!=b&&b!==a?f.slick("slickGoTo",b):void 0})})},b.initOnload?(g=!1,b.$watch("data",function(a){return null!=a?(g&&e(),f(),g=!0):void 0})):f()}}}]); \ No newline at end of file +/*! angular-slick v0.2.1 */ +"use strict";angular.module("slick",[]).directive("slick",["$timeout",function(a){return{restrict:"AEC",scope:{initOnload:"@",data:"=",currentIndex:"=",accessibility:"@",adaptiveHeight:"@",arrows:"@",asNavFor:"@",appendArrows:"@",appendDots:"@",autoplay:"@",autoplaySpeed:"@",centerMode:"@",centerPadding:"@",cssEase:"@",customPaging:"&",dots:"@",draggable:"@",easing:"@",fade:"@",focusOnSelect:"@",infinite:"@",initialSlide:"@",lazyLoad:"@",mobileFirst:"@",onBeforeChange:"&",onAfterChange:"&",onInit:"&",onReInit:"&",onSetPosition:"&",pauseOnHover:"@",pauseOnDotsHover:"@",responsive:"=",rtl:"@",slide:"@",slidesToShow:"@",slidesToScroll:"@",speed:"@",swipe:"@",swipeToSlide:"@",touchMove:"@",touchThreshold:"@",useCSS:"@",variableWidth:"@",vertical:"@",prevArrow:"@",nextArrow:"@"},link:function(b,c,d){var e,f,g;return e=function(){return a(function(){var a;return a=angular.element(c),a.slick("unslick"),a.find(".slick-list").remove(),a})},f=function(){return a(function(){var a,e,f;return f=angular.element(c),null!=b.currentIndex&&(a=b.currentIndex),e=function(a,c){return b.customPaging({slick:a,index:c})},f.slick({accessibility:"false"!==b.accessibility,adaptiveHeight:"true"===b.adaptiveHeight,arrows:"false"!==b.arrows,asNavFor:b.asNavFor?b.asNavFor:void 0,appendArrows:b.appendArrows?angular.element(b.appendArrows):angular.element(c),appendDots:b.appendDots?angular.element(b.appendDots):angular.element(c),autoplay:"true"===b.autoplay,autoplaySpeed:null!=b.autoplaySpeed?parseInt(b.autoplaySpeed,10):3e3,centerMode:"true"===b.centerMode,centerPadding:b.centerPadding||"50px",cssEase:b.cssEase||"ease",customPaging:d.customPaging?e:void 0,dots:"true"===b.dots,draggable:"false"!==b.draggable,easing:b.easing||"linear",fade:"true"===b.fade,focusOnSelect:"true"===b.focusOnSelect,mobileFirst:"true"===b.mobileFirst,infinite:"false"!==b.infinite,initialSlide:null!=b.initialSlide?parseInt(b.initialSlide,10):0,lazyLoad:b.lazyLoad||"ondemand",beforeChange:d.onBeforeChange?b.onBeforeChange:void 0,onReInit:d.onReInit?b.onReInit:void 0,onSetPosition:d.onSetPosition?b.onSetPosition:void 0,pauseOnHover:"false"!==b.pauseOnHover,responsive:b.responsive||void 0,rtl:"true"===b.rtl,slide:b.slide||"div",slidesToShow:null!=b.slidesToShow?parseInt(b.slidesToShow,10):1,slidesToScroll:null!=b.slidesToScroll?parseInt(b.slidesToScroll,10):1,speed:null!=b.speed?parseInt(b.speed,10):300,swipe:"false"!==b.swipe,swipeToSlide:"true"===b.swipeToSlide,touchMove:"false"!==b.touchMove,touchThreshold:b.touchThreshold?parseInt(b.touchThreshold,10):5,useCSS:"false"!==b.useCSS,variableWidth:"true"===b.variableWidth,vertical:"true"===b.vertical,prevArrow:b.prevArrow?angular.element(b.prevArrow):void 0,nextArrow:b.nextArrow?angular.element(b.nextArrow):void 0}),f.on("init",function(c){return d.onInit&&b.onInit(),null!=a?c.slideHandler(a):void 0}),f.on("reInit",function(a){return d.onReInit?b.onReInit():void 0}),f.on("setPosition",function(a){return d.onSetPosition?b.onSetPosition():void 0}),f.on("swipe",function(a){return d.onSwipe?b.onSwipe():void 0}),f.on("afterChange",function(c,d,e,f){return b.onAfterChange&&b.onAfterChange(),null!=a?b.$apply(function(){return a=e,b.currentIndex=e}):void 0}),f.on("beforeChange",function(a){return d.onBeforeChange?b.onBeforeChange():void 0}),f.on("breakpoint",function(a){return d.onBreakpoint?b.onBreakpoint():void 0}),f.on("destroy",function(a){return d.onDestroy?b.onDestroy():void 0}),f.on("edge",function(a){return d.onEdge?b.onEdge():void 0}),b.$watch("currentIndex",function(b,c){return null!=a&&null!=b&&b!==a?f.slick("slickGoTo",b):void 0})})},b.initOnload?(g=!1,b.$watch("data",function(a,b){return null!=a?(g&&e(),f(),g=!0):void 0})):f()}}}]); \ No newline at end of file