From 27b40a79c3f1ac011ddbad5c8d5b4cc9cd853a6e Mon Sep 17 00:00:00 2001 From: kenwheeler Date: Thu, 27 Mar 2014 21:35:05 -0400 Subject: [PATCH] Version 1.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding namespaced events, css class namespaces, refactoring/DRY’ing, fixing active class bug, adding visible class & updating manifest files --- bower.json | 2 +- css/slick.css | 20 +- js/slick.js | 864 ++++++++++++++++++++++------------------------ js/slick.min.js | 2 +- slick.jquery.json | 4 +- slick.js | 864 ++++++++++++++++++++++------------------------ slick.min.js | 2 +- 7 files changed, 835 insertions(+), 923 deletions(-) diff --git a/bower.json b/bower.json index 0f829e7b0..677482287 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "slick-carousel", "main": "slick.js", - "version": "1.0.1", + "version": "1.2.0", "homepage": "https://github.com/kenwheeler/slick", "authors": [ "Ken Wheeler " diff --git a/css/slick.css b/css/slick.css index 795854348..e4d0615b6 100644 --- a/css/slick.css +++ b/css/slick.css @@ -6,17 +6,17 @@ .slick-slider .slick-list { overflow: hidden; display: block; margin: 0px; padding: 0px; } .slick-slider .slick-track { position: relative; left: 0px; top: 0px; display: table;} .slick-slider .slick-track:after { content: ""; display: table; clear: both; } -.slick-slider .slide { float: left; height: 100%; min-height: 1px; } -.slick-slider .slide img { display: block; } -.slick-slider .slide { display: none; } -.slick-initialized .slide { display: table-cell; } +.slick-slider .slick-slide { float: left; height: 100%; min-height: 1px; } +.slick-slider .slick-slide img { display: block; } +.slick-slider .slick-slide { display: none; } +.slick-initialized .slick-slide { display: table-cell; } /* Loading States */ .slick-loading .slick-track { visibility: hidden; } .slick-loading .slick-list { background: #fff url(../img/ajax-loader.gif) center center no-repeat; } -.slick-loading .slide { visibility: hidden; } -.slide.loading { background: url(../img/ajax-loader.gif) center center no-repeat; position: relative;} +.slick-loading .slick-slide { visibility: hidden; } +.slick-slide.loading { background: url(../img/ajax-loader.gif) center center no-repeat; position: relative;} /* Arrows */ @@ -24,8 +24,8 @@ .slick-slider .slick-next { position: absolute; background: url('../img/sprite.png') -90px -40px no-repeat; display: block; height: 40px; width: 30px; text-indent: -9999px; top: 50%; margin-top: -20px; right: -25px; padding: 0px; } .slick-slider .slick-prev:focus { outline: none } .slick-slider .slick-next:focus { outline: none } -.slick-slider .slick-next.disabled { background-position: -90px -90px } -.slick-slider .slick-prev.disabled { background-position: -50px -90px } +.slick-slider .slick-next.slick-disabled { background-position: -90px -90px } +.slick-slider .slick-prev.slick-disabled { background-position: -50px -90px } @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min--moz-device-pixel-ratio: 1.5), only screen and (min-resolution: 240dpi) { .slick-slider .slick-next { background: url('../img/sprite@2x.png') -90px -40px no-repeat; background-size: 900px 200px; } .slick-slider .slick-prev { background: url('../img/sprite@2x.png') -50px -40px no-repeat; background-size: 900px 200px; -webkit-background-size: 900px 200px; } @@ -35,7 +35,7 @@ .slick-dots { position: absolute; bottom: -30px; list-style: none; display: block; text-align: center; padding: 0px; width: 100%;} .slick-dots li { position: relative; display: inline-block; background: url('../img/sprite.png') -200px -50px no-repeat; height: 5px; width: 5px; text-indent: -9999px; margin: 0px 10px; padding: 0px; } -.slick-dots li.active { background-position: -150px -50px } +.slick-dots li.slick-active { background-position: -150px -50px } .slick-dots li a { display: block; height: 10px; width: 10px; outline: none } @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min--moz-device-pixel-ratio: 1.5), only screen and (min-resolution: 240dpi) { .slick-dots li { background: url('../img/sprite@2x.png') -200px -50px no-repeat; background-size: 900px 200px; } @@ -44,4 +44,4 @@ /* Draggable */ .slick-list.draggable { -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } -.slick-list.dragging { cursor: pointer; cursor: hand; } +.slick-list.dragging { cursor: pointer; cursor: hand; } \ No newline at end of file diff --git a/js/slick.js b/js/slick.js index 5fba7b157..c863d6e46 100644 --- a/js/slick.js +++ b/js/slick.js @@ -1,14 +1,9 @@ /* - slick.js - Author: Ken Wheeler Date: 03/23/14 - */ - -/*global window, document, $, setInterval, clearInterval */ - +/*global window, document, define, jQuery, setInterval, clearInterval */ (function (factory) { if (typeof define === 'function' && define.amd) { @@ -19,34 +14,21 @@ }(function ($) { -var slick = window.slick || {}; + var slick = window.slick || {}; -/************ Helpers ***********/ + /************ Helpers ***********/ -// Function Binder + // Function Binder -var functionBinder = function(fn, me) { - 'use strict'; - return function() { - return fn.apply(me, arguments); + var functionBinder = function (fn, me) { + return function () { + return fn.apply(me, arguments); + }; }; -}; - -// Mobile Detect - -var mobileDetect = function() { - var check = false; - (function(a) { - if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) - check = true; - })(navigator.userAgent || navigator.vendor || window.opera); - return check; -}; /********** End Helpers *********/ - slick.slider = (function() { - 'use strict'; + slick.slider = (function () { function slider(element, settings) { @@ -98,28 +80,40 @@ var mobileDetect = function() { this.options = $.extend({}, this.defaults, settings); this.originalSettings = this.options; - var responsiveSettings = this.options.responsive || null; - - if(responsiveSettings && responsiveSettings.length > -1) { - for(var breakpoint in responsiveSettings) { - this.breakpoints.push(responsiveSettings[breakpoint].breakpoint); - this.breakpointSettings[responsiveSettings[breakpoint].breakpoint] = responsiveSettings[breakpoint].settings; + var responsiveSettings = this.options.responsive || + null; + + if (responsiveSettings && responsiveSettings.length > - + 1) { + for (var breakpoint in responsiveSettings) { + this.breakpoints.push(responsiveSettings[ + breakpoint].breakpoint); + this.breakpointSettings[responsiveSettings[ + breakpoint].breakpoint] = + responsiveSettings[breakpoint].settings; } - this.breakpoints.sort(function(a,b){return b-a}); + this.breakpoints.sort(function (a, b) { + return b - a; + }); } - this.changeSlide = functionBinder(this.changeSlide, this); - this.setPosition = functionBinder(this.setPosition, this); - this.swipeHandler = functionBinder(this.swipeHandler, this); - this.dragHandler = functionBinder(this.dragHandler, this); - this.autoPlayIterator = functionBinder(this.autoPlayIterator, this); + this.changeSlide = functionBinder(this.changeSlide, + this); + this.setPosition = functionBinder(this.setPosition, + this); + this.swipeHandler = functionBinder(this.swipeHandler, + this); + this.dragHandler = functionBinder(this.dragHandler, + this); + this.autoPlayIterator = functionBinder(this.autoPlayIterator, + this); this.init(); } - slider.prototype.init = function() { + slider.prototype.init = function () { if (!$(this.slider).hasClass('slick-initialized')) { @@ -136,17 +130,19 @@ var mobileDetect = function() { }; - slider.prototype.getAnimType = function() { + slider.prototype.getAnimType = function () { if (document.body.style.MozTransform !== undefined) { this.animType = 'MozTransform'; - } else if (document.body.style.webkitTransform !== undefined) { + } else if (document.body.style.webkitTransform !== + undefined) { this.animType = "webkitTransform"; - } else if (document.body.style.msTransform !== undefined) { + } else if (document.body.style.msTransform !== + undefined) { this.animType = "msTransform"; @@ -160,7 +156,7 @@ var mobileDetect = function() { }; - slider.prototype.autoPlay = function() { + slider.prototype.autoPlay = function () { if (this.autoPlayTimer) { @@ -168,21 +164,24 @@ var mobileDetect = function() { } - this.autoPlayTimer = setInterval(this.autoPlayIterator, this.options.autoplaySpeed); + this.autoPlayTimer = setInterval(this.autoPlayIterator, + this.options.autoplaySpeed); }; - slider.prototype.autoPlayIterator = function() { + slider.prototype.autoPlayIterator = function () { if (this.options.infinite === false) { if (this.direction === 1) { - if ((this.currentSlide + 1) === this.slideCount - 1) { + if ((this.currentSlide + 1) === this.slideCount - + 1) { this.direction = 0; } - this.slideHandler(this.currentSlide + this.options.slidesToScroll); + this.slideHandler(this.currentSlide + this.options + .slidesToScroll); } else { @@ -192,7 +191,8 @@ var mobileDetect = function() { } - this.slideHandler(this.currentSlide - this.options.slidesToScroll); + this.slideHandler(this.currentSlide - this.options + .slidesToScroll); } @@ -204,34 +204,43 @@ var mobileDetect = function() { }; - slider.prototype.checkResponsive = function() { + slider.prototype.checkResponsive = function () { - if(this.originalSettings.responsive && this.originalSettings.responsive.length > -1) { + if (this.originalSettings.responsive && this.originalSettings + .responsive.length > -1) { var targetBreakpoint = null; - for(var breakpoint in this.breakpoints) { - if($(window).width() < this.breakpoints[breakpoint]) { - targetBreakpoint = this.breakpoints[breakpoint]; + for (var breakpoint in this.breakpoints) { + if ($(window).width() < this.breakpoints[ + breakpoint]) { + targetBreakpoint = this.breakpoints[ + breakpoint]; } } - if(targetBreakpoint !== null) { - if(this.activeBreakpoint !== null) { - if(targetBreakpoint !== this.activeBreakpoint) { - this.activeBreakpoint = targetBreakpoint; - this.options = $.extend({}, this.defaults, this.breakpointSettings[targetBreakpoint]); + if (targetBreakpoint !== null) { + if (this.activeBreakpoint !== null) { + if (targetBreakpoint !== this.activeBreakpoint) { + this.activeBreakpoint = + targetBreakpoint; + this.options = $.extend({}, this.defaults, + this.breakpointSettings[ + targetBreakpoint]); this.refresh(); } } else { this.activeBreakpoint = targetBreakpoint; - this.options = $.extend({}, this.defaults, this.breakpointSettings[targetBreakpoint]); + this.options = $.extend({}, this.defaults, + this.breakpointSettings[ + targetBreakpoint]); this.refresh(); } } else { - if(this.activeBreakpoint !== null) { + if (this.activeBreakpoint !== null) { this.activeBreakpoint = null; - this.options = $.extend({}, this.defaults, this.originalSettings); + this.options = $.extend({}, this.defaults, + this.originalSettings); this.refresh(); } } @@ -239,7 +248,7 @@ var mobileDetect = function() { } }; - slider.prototype.startLoad = function() { + slider.prototype.startLoad = function () { if (this.options.arrows === true) { @@ -258,7 +267,7 @@ var mobileDetect = function() { }; - slider.prototype.loadSlider = function() { + slider.prototype.loadSlider = function () { var self = this; @@ -266,13 +275,13 @@ var mobileDetect = function() { self.slideTrack.animate({ opacity: 1 - }, this.options.speed, function() { + }, this.options.speed, function () { self.setPosition(); }); - if(document.readyState !== "complete") { + if (document.readyState !== "complete") { - $(window).load(function() { + $(window).load(function () { if (self.options.arrows === true) { @@ -324,70 +333,87 @@ var mobileDetect = function() { }; - slider.prototype.setValues = function() { + slider.prototype.setValues = function () { this.listWidth = this.list.innerWidth(); - this.slideWidth = Math.ceil(this.listWidth / this.options.slidesToShow); + this.slideWidth = Math.ceil(this.listWidth / this.options + .slidesToShow); }; - slider.prototype.buildOut = function() { + slider.prototype.buildOut = function () { var i; - this.slides = $(this.options.slide + ':not(.cloned)', this.slider).addClass('slide'); + this.slides = $(this.options.slide + + ':not(.slick-cloned)', this.slider).addClass( + 'slick-slide'); this.slideCount = this.slides.length; - if((this.slideCount % this.options.slidesToScroll) !== 0 && this.options.slidesToShow !== 1) { - - var placeholders = Math.abs(this.options.slidesToScroll - (this.slideCount % this.options.slidesToScroll)); - for(i=0; i').appendTo(this.slider).addClass('slide placeholder'); + if ((this.slideCount % this.options.slidesToScroll) !== + 0 && this.options.slidesToShow !== 1) { + + var placeholders = Math.abs(this.options.slidesToScroll - + (this.slideCount % this.options.slidesToScroll) + ); + for (i = 0; i < placeholders; i++) { + $('
').appendTo(this.slider).addClass( + 'slick-slide slick-placeholder'); } - this.slides = $('.slide:not(.cloned)', this.slider); + this.slides = $('.slick-slide:not(.slick-cloned)', + this.slider); this.slideCount = this.slides.length; } this.slider.addClass("slick-slider"); - this.slideTrack = this.slides.wrapAll('
').parent(); - this.list = this.slideTrack.wrap('
').parent(); + this.slideTrack = this.slides.wrapAll( + '
').parent(); + this.list = this.slideTrack.wrap( + '
').parent(); this.slideTrack.css('opacity', 0); if (this.options.arrows === true) { - this.prevArrow = $('Previous').appendTo(this.slider).addClass('slick-prev'); - this.nextArrow = $('Next').appendTo(this.slider).addClass('slick-next'); + this.prevArrow = $( + 'Previous').appendTo( + this.slider).addClass('slick-prev'); + this.nextArrow = $( + 'Next').appendTo( + this.slider).addClass('slick-next'); if (this.options.infinite !== true) { - this.prevArrow.addClass('disabled'); + this.prevArrow.addClass('slick-disabled'); } } if (this.options.dots === true) { - this.dots = $('
    ').appendTo(this.slider); + this.dots = $('
      ').appendTo( + this.slider); for (i = 1; i <= this.slideCount; i += 1) { - $('
    • ' + i + '
    • ').appendTo(this.dots); + $('
    • ' + i + + '
    • ').appendTo(this.dots); } - if(this.options.slidesToScroll > 1) { + if (this.options.slidesToScroll > 1) { this.dots.find('li').hide(); - var i = 0; - while(i < this.slideCount) { + i = 0; + while (i < this.slideCount) { $(this.dots.find('li').get(i)).show(); i = i + this.options.slidesToScroll; } } - this.dots.find('li').first().addClass('active'); + this.dots.find('li').first().addClass( + 'slick-active'); } - if (this.options.draggable == true) { + if (this.options.draggable === true) { this.list.addClass('draggable'); } @@ -395,150 +421,171 @@ var mobileDetect = function() { var slideIndex = null; - for(i=this.slideCount; i>(this.slideCount - this.options.slidesToShow); i--) { - slideIndex = i -1; - $(this.slides[slideIndex]).clone().prependTo(this.slideTrack).addClass('cloned'); + for (i = this.slideCount; i > (this.slideCount - + this.options.slidesToShow); i--) { + slideIndex = i - 1; + $(this.slides[slideIndex]).clone().prependTo( + this.slideTrack).addClass('slick-cloned'); } - for(i=0; i= (this.slideCount / + this.options.slidesToScroll * this.options.slidesToShow + ) - this.options.slidesToScroll) { + this.nextArrow.addClass('slick-disabled'); + this.prevArrow.removeClass('slick-disabled'); + } else { + this.prevArrow.removeClass('slick-disabled'); + this.nextArrow.removeClass('slick-disabled'); + } + } + + this.setSlideClasses(this.currentSlide); + + }; + + slider.prototype.slideHandler = function (index) { + + var targetSlide, slideLeft, targetLeft = + null, self = this; targetSlide = index; - targetLeft = ((targetSlide * this.slideWidth) * -1) + this.slideOffset; - slideLeft = ((this.currentSlide * this.slideWidth) * -1) + this.slideOffset; + targetLeft = ((targetSlide * this.slideWidth) * -1) + + this.slideOffset; + slideLeft = ((this.currentSlide * this.slideWidth) * -1) + + this.slideOffset; if (self.options.autoplay === true) { clearInterval(this.autoPlayTimer); @@ -596,32 +702,10 @@ var mobileDetect = function() { this.animating = true; - this.animateSlide(targetLeft, function(){ + this.animateSlide(targetLeft, function () { - self.animating = false; - - self.currentSlide = self.slideCount - self.options.slidesToScroll; - - self.setPosition(); - - if (self.swipeLeft !== null) { - self.swipeLeft = null; - } - - if (self.options.dots) { - self.updateDots(); - } - - if (self.options.autoplay === true) { - self.autoPlay(); - } - - if(self.options.onAfterChange !== null) { - self.options.onAfterChange.call(); - } - - self.slides.removeClass('active'); - $(self.slides.get(targetSlide)).addClass('active'); + self.postSlide(self.slideCount - self.options + .slidesToScroll); }); @@ -639,32 +723,9 @@ var mobileDetect = function() { this.animating = true; - this.animateSlide(targetLeft, function(){ - - self.animating = false; - - self.currentSlide = 0; + this.animateSlide(targetLeft, function () { - self.setPosition(); - - if (self.swipeLeft !== null) { - self.swipeLeft = null; - } - - if (self.options.dots) { - self.updateDots(); - } - - if (self.options.autoplay === true) { - self.autoPlay(); - } - - if(self.options.onAfterChange !== null) { - self.options.onAfterChange.call(); - } - - self.slides.removeClass('active'); - $(self.slides.get(targetSlide)).addClass('active'); + self.postSlide(0); }); @@ -680,45 +741,9 @@ var mobileDetect = function() { this.animating = true; - this.animateSlide(targetLeft, function(){ - - self.animating = false; - - self.currentSlide = targetSlide; - - self.setPosition(); - - if (self.swipeLeft !== null) { - self.swipeLeft = null; - } - - if (self.options.dots) { - self.updateDots(); - } - - if (self.options.autoplay === true) { - self.autoPlay(); - } + this.animateSlide(targetLeft, function () { - if(self.options.onAfterChange !== null) { - self.options.onAfterChange.call(); - } - - self.slides.removeClass('active'); - $(self.slides.get(targetSlide)).addClass('active'); - - if (self.options.arrows === true && self.options.infinite !== true) { - if (self.currentSlide === 0) { - self.prevArrow.addClass('disabled'); - self.nextArrow.removeClass('disabled'); - } else if (self.currentSlide >= (self.slideCount / self.options.slidesToScroll * self.options.slidesToShow) - self.options.slidesToScroll) { - self.nextArrow.addClass('disabled'); - self.prevArrow.removeClass('disabled'); - } else { - self.prevArrow.removeClass('disabled'); - self.nextArrow.removeClass('disabled'); - } - } + self.postSlide(targetSlide); }); @@ -726,48 +751,93 @@ var mobileDetect = function() { }; - slider.prototype.dragHandler = function(event) { + slider.prototype.swipeHandler = function (event) { var animProps = {}, curLeft, newLeft = null; - curLeft = ((this.currentSlide * this.slideWidth) * -1) + this.slideOffset; + curLeft = ((this.currentSlide * this.slideWidth) * -1) + + this.slideOffset; - this.touchObject.minSwipe = this.slideWidth / this.options.touchThreshold; + if (event.data.kind == 'touch') { + this.touchObject.fingerCount = event.originalEvent.touches + .length; + } + + this.touchObject.minSwipe = this.slideWidth / this.options + .touchThreshold; switch (event.data.action) { - case 'start': + case 'start': + + if (this.touchObject.fingerCount === 1 || event.data + .kind == 'drag') { + + if (event.data.kind == 'touch') { + this.touchObject.startX = event.originalEvent + .touches[0].pageX; + this.touchObject.startY = event.originalEvent + .touches[0].pageY; + this.touchObject.curX = event.originalEvent + .touches[0].pageX; + this.touchObject.curY = event.originalEvent + .touches[0].pageY; + } else { + this.list.addClass('dragging'); + this.touchObject.startX = event.clientX; + this.touchObject.startY = event.clientY; + this.touchObject.curX = event.clientX; + this.touchObject.curY = event.clientY; + } + + } else { + this.touchObject = {}; - this.list.addClass('dragging'); + } - this.touchObject.startX = event.clientX; - this.touchObject.startY = event.clientY; - this.touchObject.curX = event.clientX; - this.touchObject.curY = event.clientY; + break; - break; + case 'move': - case 'move': + if ((event.originalEvent.touches && event.originalEvent + .touches.length === 1) || event.data.kind == + 'drag') { - this.touchObject.curX = event.clientX; - this.touchObject.curY = event.clientY; + if (event.data.kind == 'touch') { + this.touchObject.curX = event.originalEvent + .touches[0].pageX; + this.touchObject.curY = event.originalEvent + .touches[0].pageY; + } else { + this.touchObject.curX = event.clientX; + this.touchObject.curY = event.clientY; + } - this.touchObject.swipeLength = Math.round(Math.sqrt(Math.pow(this.touchObject.curX - this.touchObject.startX, 2))); + this.touchObject.swipeLength = Math.round(Math.sqrt( + Math.pow(this.touchObject.curX - this.touchObject + .startX, 2))); - if (this.swipeDirection() !== 'up' && this.swipeDirection() !== 'down') { + if (this.swipeDirection() !== 'up' && this.swipeDirection() !== + 'down') { event.originalEvent.preventDefault(); - if (this.touchObject.curX > this.touchObject.startX) { + if (this.touchObject.curX > this.touchObject + .startX) { - if(this.options.touchMove == true) { + if (this.options.touchMove === true) { - newLeft = curLeft + this.touchObject.swipeLength; - if (this.transformsEnabled === false) { - this.slideTrack.css('left', newLeft); + newLeft = curLeft + this.touchObject + .swipeLength; + if (this.transformsEnabled === + false) { + this.slideTrack.css('left', + newLeft); } else { - animProps[this.animType] = "translate(" + newLeft + "px, 0px)"; + animProps[this.animType] = + "translate(" + newLeft + + "px, 0px)"; this.slideTrack.css(animProps); this.swipeLeft = newLeft; } @@ -776,13 +846,18 @@ var mobileDetect = function() { } else { - if(this.options.touchMove == true) { + if (this.options.touchMove === true) { - newLeft = curLeft - this.touchObject.swipeLength; - if (this.transformsEnabled === false) { - this.slideTrack.css('left', newLeft); + newLeft = curLeft - this.touchObject + .swipeLength; + if (this.transformsEnabled === + false) { + this.slideTrack.css('left', + newLeft); } else { - animProps[this.animType] = "translate(" + newLeft + "px, 0px)"; + animProps[this.animType] = + "translate(" + newLeft + + "px, 0px)"; this.slideTrack.css(animProps); this.swipeLeft = newLeft; } @@ -793,196 +868,77 @@ var mobileDetect = function() { } - break; - - case 'end': - - this.list.removeClass('dragging'); + } else { - if (this.touchObject.curX !== 0) { + this.touchObject = {}; - if (this.touchObject.swipeLength >= this.touchObject.minSwipe) { + } - switch (this.swipeDirection()) { + break; - case 'left': + case 'end': - this.slideHandler(this.currentSlide + this.options.slidesToScroll); - this.touchObject = {}; + if ((this.touchObject.fingerCount === 0 && this.touchObject + .curX !== 0) || event.data.kind == 'drag') { - break; + if (this.touchObject.swipeLength >= this.touchObject + .minSwipe) { - case 'right': + switch (this.swipeDirection()) { - this.slideHandler(this.currentSlide - this.options.slidesToScroll); - this.touchObject = {}; + case 'left': - break; + this.slideHandler(this.currentSlide + + this.options.slidesToScroll); + this.touchObject = {}; - } + break; - } else { + case 'right': - this.slideHandler(this.currentSlide); + this.slideHandler(this.currentSlide - + this.options.slidesToScroll); this.touchObject = {}; + break; + } } else { - this.touchObject = {}; - - } - - break; - - case 'cancel': - - this.list.removeClass('dragging'); - - if(this.touchObject.startX) { this.slideHandler(this.currentSlide); this.touchObject = {}; - } - - break; - - } - - } - - slider.prototype.swipeHandler = function(event) { - - var animProps = {}, curLeft, newLeft = null; - - curLeft = ((this.currentSlide * this.slideWidth) * -1) + this.slideOffset; - - this.touchObject.fingerCount = event.originalEvent.touches.length; - - this.touchObject.minSwipe = this.slideWidth / this.options.touchThreshold; - - switch (event.data.action) { - - case 'start': - - if (this.touchObject.fingerCount === 1) { - - this.touchObject.startX = event.originalEvent.touches[0].pageX; - this.touchObject.startY = event.originalEvent.touches[0].pageY; - this.touchObject.curX = event.originalEvent.touches[0].pageX; - this.touchObject.curY = event.originalEvent.touches[0].pageY; - - } else { - - this.touchObject = {}; } - break; - - case 'move': - - if (event.originalEvent.touches.length === 1) { - - this.touchObject.curX = event.originalEvent.touches[0].pageX; - this.touchObject.curY = event.originalEvent.touches[0].pageY; - - this.touchObject.swipeLength = Math.round(Math.sqrt(Math.pow(this.touchObject.curX - this.touchObject.startX, 2))); - - if (this.swipeDirection() !== 'up' && this.swipeDirection() !== 'down') { - - event.originalEvent.preventDefault(); - - if (this.touchObject.curX > this.touchObject.startX) { - - if(this.options.touchMove == true) { - - newLeft = curLeft + this.touchObject.swipeLength; - if (this.transformsEnabled === false) { - this.slideTrack.css('left', newLeft); - } else { - animProps[this.animType] = "translate(" + newLeft + "px, 0px)"; - this.slideTrack.css(animProps); - this.swipeLeft = newLeft; - } - - } - - } else { - - if(this.options.touchMove == true) { - - newLeft = curLeft - this.touchObject.swipeLength; - if (this.transformsEnabled === false) { - this.slideTrack.css('left', newLeft); - } else { - animProps[this.animType] = "translate(" + newLeft + "px, 0px)"; - this.slideTrack.css(animProps); - this.swipeLeft = newLeft; - } - - } - - } - - } - - } else { - - this.touchObject = {}; - + if (event.data.kind == 'drag') { + this.list.removeClass('dragging'); } - break; - - case 'end': - - if (this.touchObject.fingerCount === 0 && this.touchObject.curX !== 0) { - - if (this.touchObject.swipeLength >= this.touchObject.minSwipe) { - - switch (this.swipeDirection()) { - - case 'left': - - this.slideHandler(this.currentSlide + this.options.slidesToScroll); - this.touchObject = {}; - - break; - - case 'right': - - this.slideHandler(this.currentSlide - this.options.slidesToScroll); - this.touchObject = {}; - - break; - - } - - } else { - - this.slideHandler(this.currentSlide); - this.touchObject = {}; + } else { - } + this.touchObject = {}; - } else { + } - this.touchObject = {}; + break; - } + case 'cancel': - break; + this.list.removeClass('dragging'); - case 'cancel': + if (this.touchObject.startX) { + this.slideHandler(this.currentSlide); + this.touchObject = {}; + } - break; + break; } }; - slider.prototype.swipeDirection = function() { + slider.prototype.swipeDirection = function () { var xDist, yDist, r, swipeAngle; @@ -1009,9 +965,10 @@ var mobileDetect = function() { }; - slider.prototype.refresh = function() { + slider.prototype.refresh = function () { this.destroy(); + this.autoPlayTimer = null; this.currentSlide = 0; this.currentLeft = null; @@ -1035,6 +992,7 @@ var mobileDetect = function() { if (!$(this.slider).hasClass('slick-initialized')) { $(this.slider).addClass('slick-initialized'); + this.buildOut(); this.setValues(); this.getAnimType(); @@ -1045,45 +1003,43 @@ var mobileDetect = function() { } - } + }; - slider.prototype.destroy = function() { - $('.cloned', this.slider).remove(); - $('.placeholder', this.slider).remove(); - if(this.dots) { + slider.prototype.destroy = function () { + $('.slick-cloned', this.slider).remove(); + $('.slick-placeholder', this.slider).remove(); + if (this.dots) { this.dots.remove(); } - if(this.prevArrow) { + if (this.prevArrow) { this.prevArrow.remove(); this.nextArrow.remove(); } this.slides.unwrap().unwrap(); - this.slides.removeClass('slide').width(''); + this.slides.removeClass( + 'slick-slide slick-active slick-visible').width(''); this.slider.removeClass('slick-slider'); this.slider.removeClass('slick-initialized'); - } + }; return slider; }()); -$.fn.slick = function(options) { - - 'use strict'; + $.fn.slick = function (options) { + return this.each(function () { - return this.each(function(index) { + this.slider = new slick.slider(this, options); - this.slider = new slick.slider(this, options); - - }); -} + }); + }; -$.fn.unslick = function(){ - return this.each(function(index) { + $.fn.unslick = function () { + return this.each(function () { - this.slider.destroy(); + this.slider.destroy(); - }); -} + }); + }; })); \ No newline at end of file diff --git a/js/slick.min.js b/js/slick.min.js index 36998c1fb..00d0e2eb1 100644 --- a/js/slick.min.js +++ b/js/slick.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){var b=window.slick||{},c=function(a,b){"use strict";return function(){return a.apply(b,arguments)}};b.slider=function(){"use strict";function b(b,d){this.defaults={autoplay:!1,autoplaySpeed:3e3,dots:!1,draggable:!0,arrows:!0,infinite:!0,onBeforeChange:null,onAfterChange:null,responsive:null,slide:"div",slidesToShow:1,slidesToScroll:1,speed:300,swipe:!0,touchMove:!0,touchThreshold:5},this.activeBreakpoint=null,this.animating=!1,this.animType=null,this.autoPlayTimer=null,this.breakpoints=[],this.breakpointSettings=[],this.currentSlide=0,this.currentLeft=null,this.direction=1,this.dots=null,this.listWidth=null,this.loadIndex=0,this.nextArrow=null,this.prevArrow=null,this.slideCount=null,this.slideWidth=null,this.slideTrack=null,this.slides=null,this.sliding=!1,this.slideOffset=0,this.slider=a(b),this.swipeLeft=null,this.list=null,this.touchObject={},this.transformsEnabled=!1,this.options=a.extend({},this.defaults,d),this.originalSettings=this.options;var e=this.options.responsive||null;if(e&&e.length>-1){for(var f in e)this.breakpoints.push(e[f].breakpoint),this.breakpointSettings[e[f].breakpoint]=e[f].settings;this.breakpoints.sort(function(a,b){return b-a})}this.changeSlide=c(this.changeSlide,this),this.setPosition=c(this.setPosition,this),this.swipeHandler=c(this.swipeHandler,this),this.dragHandler=c(this.dragHandler,this),this.autoPlayIterator=c(this.autoPlayIterator,this),this.init()}return b.prototype.init=function(){a(this.slider).hasClass("slick-initialized")||(a(this.slider).addClass("slick-initialized"),this.buildOut(),this.setValues(),this.getAnimType(),this.setPosition(),this.startLoad(),this.loadSlider(),this.initializeEvents(),this.checkResponsive())},b.prototype.getAnimType=function(){void 0!==document.body.style.MozTransform?this.animType="MozTransform":void 0!==document.body.style.webkitTransform?this.animType="webkitTransform":void 0!==document.body.style.msTransform&&(this.animType="msTransform"),null!==this.animType&&(this.transformsEnabled=!0)},b.prototype.autoPlay=function(){this.autoPlayTimer&&clearInterval(this.autoPlayTimer),this.autoPlayTimer=setInterval(this.autoPlayIterator,this.options.autoplaySpeed)},b.prototype.autoPlayIterator=function(){this.options.infinite===!1?1===this.direction?(this.currentSlide+1===this.slideCount-1&&(this.direction=0),this.slideHandler(this.currentSlide+this.options.slidesToScroll)):(0===this.currentSlide-1&&(this.direction=1),this.slideHandler(this.currentSlide-this.options.slidesToScroll)):this.slideHandler(this.currentSlide+this.options.slidesToScroll)},b.prototype.checkResponsive=function(){if(this.originalSettings.responsive&&this.originalSettings.responsive.length>-1){var b=null;for(var c in this.breakpoints)a(window).width()b;b++)a("
      ").appendTo(this.slider).addClass("slide placeholder");this.slides=a(".slide:not(.cloned)",this.slider),this.slideCount=this.slides.length}if(this.slider.addClass("slick-slider"),this.slideTrack=this.slides.wrapAll('
      ').parent(),this.list=this.slideTrack.wrap('
      ').parent(),this.slideTrack.css("opacity",0),this.options.arrows===!0&&(this.prevArrow=a('Previous').appendTo(this.slider).addClass("slick-prev"),this.nextArrow=a('Next').appendTo(this.slider).addClass("slick-next"),this.options.infinite!==!0&&this.prevArrow.addClass("disabled")),this.options.dots===!0){for(this.dots=a('
        ').appendTo(this.slider),b=1;b<=this.slideCount;b+=1)a('
      • '+b+"
      • ").appendTo(this.dots);if(this.options.slidesToScroll>1){this.dots.find("li").hide();for(var b=0;bthis.slideCount-this.options.slidesToShow;b--)d=b-1,a(this.slides[d]).clone().prependTo(this.slideTrack).addClass("cloned");for(b=0;bd){if(this.options.infinite!==!0)return this.animateSlide(e),!1;this.animating=!0,this.animateSlide(f,function(){g.animating=!1,g.currentSlide=g.slideCount-g.options.slidesToScroll,g.setPosition(),null!==g.swipeLeft&&(g.swipeLeft=null),g.options.dots&&g.updateDots(),g.options.autoplay===!0&&g.autoPlay(),null!==g.options.onAfterChange&&g.options.onAfterChange.call(),g.slides.removeClass("active"),a(g.slides.get(d)).addClass("active")})}else if(d>this.slideCount-1){if(this.options.infinite!==!0)return this.animateSlide(e),!1;this.animating=!0,this.animateSlide(f,function(){g.animating=!1,g.currentSlide=0,g.setPosition(),null!==g.swipeLeft&&(g.swipeLeft=null),g.options.dots&&g.updateDots(),g.options.autoplay===!0&&g.autoPlay(),null!==g.options.onAfterChange&&g.options.onAfterChange.call(),g.slides.removeClass("active"),a(g.slides.get(d)).addClass("active")})}else this.animating=!0,this.animateSlide(f,function(){g.animating=!1,g.currentSlide=d,g.setPosition(),null!==g.swipeLeft&&(g.swipeLeft=null),g.options.dots&&g.updateDots(),g.options.autoplay===!0&&g.autoPlay(),null!==g.options.onAfterChange&&g.options.onAfterChange.call(),g.slides.removeClass("active"),a(g.slides.get(d)).addClass("active"),g.options.arrows===!0&&g.options.infinite!==!0&&(0===g.currentSlide?(g.prevArrow.addClass("disabled"),g.nextArrow.removeClass("disabled")):g.currentSlide>=g.slideCount/g.options.slidesToScroll*g.options.slidesToShow-g.options.slidesToScroll?(g.nextArrow.addClass("disabled"),g.prevArrow.removeClass("disabled")):(g.prevArrow.removeClass("disabled"),g.nextArrow.removeClass("disabled")))})},b.prototype.dragHandler=function(a){var c,b={},d=null;switch(c=-1*this.currentSlide*this.slideWidth+this.slideOffset,this.touchObject.minSwipe=this.slideWidth/this.options.touchThreshold,a.data.action){case"start":this.list.addClass("dragging"),this.touchObject.startX=a.clientX,this.touchObject.startY=a.clientY,this.touchObject.curX=a.clientX,this.touchObject.curY=a.clientY;break;case"move":this.touchObject.curX=a.clientX,this.touchObject.curY=a.clientY,this.touchObject.swipeLength=Math.round(Math.sqrt(Math.pow(this.touchObject.curX-this.touchObject.startX,2))),"up"!==this.swipeDirection()&&"down"!==this.swipeDirection()&&(a.originalEvent.preventDefault(),this.touchObject.curX>this.touchObject.startX?1==this.options.touchMove&&(d=c+this.touchObject.swipeLength,this.transformsEnabled===!1?this.slideTrack.css("left",d):(b[this.animType]="translate("+d+"px, 0px)",this.slideTrack.css(b),this.swipeLeft=d)):1==this.options.touchMove&&(d=c-this.touchObject.swipeLength,this.transformsEnabled===!1?this.slideTrack.css("left",d):(b[this.animType]="translate("+d+"px, 0px)",this.slideTrack.css(b),this.swipeLeft=d)));break;case"end":if(this.list.removeClass("dragging"),0!==this.touchObject.curX)if(this.touchObject.swipeLength>=this.touchObject.minSwipe)switch(this.swipeDirection()){case"left":this.slideHandler(this.currentSlide+this.options.slidesToScroll),this.touchObject={};break;case"right":this.slideHandler(this.currentSlide-this.options.slidesToScroll),this.touchObject={}}else this.slideHandler(this.currentSlide),this.touchObject={};else this.touchObject={};break;case"cancel":this.list.removeClass("dragging"),this.touchObject.startX&&(this.slideHandler(this.currentSlide),this.touchObject={})}},b.prototype.swipeHandler=function(a){var c,b={},d=null;switch(c=-1*this.currentSlide*this.slideWidth+this.slideOffset,this.touchObject.fingerCount=a.originalEvent.touches.length,this.touchObject.minSwipe=this.slideWidth/this.options.touchThreshold,a.data.action){case"start":1===this.touchObject.fingerCount?(this.touchObject.startX=a.originalEvent.touches[0].pageX,this.touchObject.startY=a.originalEvent.touches[0].pageY,this.touchObject.curX=a.originalEvent.touches[0].pageX,this.touchObject.curY=a.originalEvent.touches[0].pageY):this.touchObject={};break;case"move":1===a.originalEvent.touches.length?(this.touchObject.curX=a.originalEvent.touches[0].pageX,this.touchObject.curY=a.originalEvent.touches[0].pageY,this.touchObject.swipeLength=Math.round(Math.sqrt(Math.pow(this.touchObject.curX-this.touchObject.startX,2))),"up"!==this.swipeDirection()&&"down"!==this.swipeDirection()&&(a.originalEvent.preventDefault(),this.touchObject.curX>this.touchObject.startX?1==this.options.touchMove&&(d=c+this.touchObject.swipeLength,this.transformsEnabled===!1?this.slideTrack.css("left",d):(b[this.animType]="translate("+d+"px, 0px)",this.slideTrack.css(b),this.swipeLeft=d)):1==this.options.touchMove&&(d=c-this.touchObject.swipeLength,this.transformsEnabled===!1?this.slideTrack.css("left",d):(b[this.animType]="translate("+d+"px, 0px)",this.slideTrack.css(b),this.swipeLeft=d)))):this.touchObject={};break;case"end":if(0===this.touchObject.fingerCount&&0!==this.touchObject.curX)if(this.touchObject.swipeLength>=this.touchObject.minSwipe)switch(this.swipeDirection()){case"left":this.slideHandler(this.currentSlide+this.options.slidesToScroll),this.touchObject={};break;case"right":this.slideHandler(this.currentSlide-this.options.slidesToScroll),this.touchObject={}}else this.slideHandler(this.currentSlide),this.touchObject={};else this.touchObject={};break;case"cancel":}},b.prototype.swipeDirection=function(){var a,b,c,d;return a=this.touchObject.startX-this.touchObject.curX,b=this.touchObject.startY-this.touchObject.curY,c=Math.atan2(b,a),d=Math.round(180*c/Math.PI),0>d&&(d=360-Math.abs(d)),45>=d&&d>=0?"left":360>=d&&d>=315?"left":d>=135&&225>=d?"right":d>45&&135>d?"down":"up"},b.prototype.refresh=function(){this.destroy(),this.autoPlayTimer=null,this.currentSlide=0,this.currentLeft=null,this.direction=1,this.dots=null,this.listWidth=null,this.loadIndex=0,this.nextArrow=null,this.prevArrow=null,this.slideCount=null,this.slideWidth=null,this.slideTrack=null,this.slides=null,this.sliding=!1,this.slideOffset=0,this.swipeLeft=null,this.list=null,this.touchObject={},this.transformsEnabled=!1,a(this.slider).hasClass("slick-initialized")||(a(this.slider).addClass("slick-initialized"),this.buildOut(),this.setValues(),this.getAnimType(),this.setPosition(),this.startLoad(),this.loadSlider(),this.initializeEvents())},b.prototype.destroy=function(){a(".cloned",this.slider).remove(),a(".placeholder",this.slider).remove(),this.dots&&this.dots.remove(),this.prevArrow&&(this.prevArrow.remove(),this.nextArrow.remove()),this.slides.unwrap().unwrap(),this.slides.removeClass("slide").width(""),this.slider.removeClass("slick-slider"),this.slider.removeClass("slick-initialized")},b}(),a.fn.slick=function(a){"use strict";return this.each(function(){this.slider=new b.slider(this,a)})},a.fn.unslick=function(){return this.each(function(){this.slider.destroy()})}}); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){var b=window.slick||{},c=function(a,b){return function(){return a.apply(b,arguments)}};b.slider=function(){function b(b,d){this.defaults={autoplay:!1,autoplaySpeed:3e3,dots:!1,draggable:!0,arrows:!0,infinite:!0,onBeforeChange:null,onAfterChange:null,responsive:null,slide:"div",slidesToShow:1,slidesToScroll:1,speed:300,swipe:!0,touchMove:!0,touchThreshold:5},this.activeBreakpoint=null,this.animating=!1,this.animType=null,this.autoPlayTimer=null,this.breakpoints=[],this.breakpointSettings=[],this.currentSlide=0,this.currentLeft=null,this.direction=1,this.dots=null,this.listWidth=null,this.loadIndex=0,this.nextArrow=null,this.prevArrow=null,this.slideCount=null,this.slideWidth=null,this.slideTrack=null,this.slides=null,this.sliding=!1,this.slideOffset=0,this.slider=a(b),this.swipeLeft=null,this.list=null,this.touchObject={},this.transformsEnabled=!1,this.options=a.extend({},this.defaults,d),this.originalSettings=this.options;var e=this.options.responsive||null;if(e&&e.length>-1){for(var f in e)this.breakpoints.push(e[f].breakpoint),this.breakpointSettings[e[f].breakpoint]=e[f].settings;this.breakpoints.sort(function(a,b){return b-a})}this.changeSlide=c(this.changeSlide,this),this.setPosition=c(this.setPosition,this),this.swipeHandler=c(this.swipeHandler,this),this.dragHandler=c(this.dragHandler,this),this.autoPlayIterator=c(this.autoPlayIterator,this),this.init()}return b.prototype.init=function(){a(this.slider).hasClass("slick-initialized")||(a(this.slider).addClass("slick-initialized"),this.buildOut(),this.setValues(),this.getAnimType(),this.setPosition(),this.startLoad(),this.loadSlider(),this.initializeEvents(),this.checkResponsive())},b.prototype.getAnimType=function(){void 0!==document.body.style.MozTransform?this.animType="MozTransform":void 0!==document.body.style.webkitTransform?this.animType="webkitTransform":void 0!==document.body.style.msTransform&&(this.animType="msTransform"),null!==this.animType&&(this.transformsEnabled=!0)},b.prototype.autoPlay=function(){this.autoPlayTimer&&clearInterval(this.autoPlayTimer),this.autoPlayTimer=setInterval(this.autoPlayIterator,this.options.autoplaySpeed)},b.prototype.autoPlayIterator=function(){this.options.infinite===!1?1===this.direction?(this.currentSlide+1===this.slideCount-1&&(this.direction=0),this.slideHandler(this.currentSlide+this.options.slidesToScroll)):(0===this.currentSlide-1&&(this.direction=1),this.slideHandler(this.currentSlide-this.options.slidesToScroll)):this.slideHandler(this.currentSlide+this.options.slidesToScroll)},b.prototype.checkResponsive=function(){if(this.originalSettings.responsive&&this.originalSettings.responsive.length>-1){var b=null;for(var c in this.breakpoints)a(window).width()b;b++)a("
        ").appendTo(this.slider).addClass("slick-slide slick-placeholder");this.slides=a(".slick-slide:not(.slick-cloned)",this.slider),this.slideCount=this.slides.length}if(this.slider.addClass("slick-slider"),this.slideTrack=this.slides.wrapAll('
        ').parent(),this.list=this.slideTrack.wrap('
        ').parent(),this.slideTrack.css("opacity",0),this.options.arrows===!0&&(this.prevArrow=a('Previous').appendTo(this.slider).addClass("slick-prev"),this.nextArrow=a('Next').appendTo(this.slider).addClass("slick-next"),this.options.infinite!==!0&&this.prevArrow.addClass("slick-disabled")),this.options.dots===!0){for(this.dots=a('
          ').appendTo(this.slider),b=1;b<=this.slideCount;b+=1)a('
        • '+b+"
        • ").appendTo(this.dots);if(this.options.slidesToScroll>1)for(this.dots.find("li").hide(),b=0;bthis.slideCount-this.options.slidesToShow;b--)d=b-1,a(this.slides[d]).clone().prependTo(this.slideTrack).addClass("slick-cloned");for(b=0;bd;d++)a(this.slides.get(d)).addClass("slick-visible")},b.prototype.postSlide=function(a){this.animating=!1,this.currentSlide=a,this.setPosition(),null!==this.swipeLeft&&(this.swipeLeft=null),this.options.dots&&this.updateDots(),this.options.autoplay===!0&&this.autoPlay(),null!==this.options.onAfterChange&&this.options.onAfterChange.call(),this.options.arrows===!0&&this.options.infinite!==!0&&(0===this.currentSlide?(this.prevArrow.addClass("slick-disabled"),this.nextArrow.removeClass("slick-disabled")):this.currentSlide>=this.slideCount/this.options.slidesToScroll*this.options.slidesToShow-this.options.slidesToScroll?(this.nextArrow.addClass("slick-disabled"),this.prevArrow.removeClass("slick-disabled")):(this.prevArrow.removeClass("slick-disabled"),this.nextArrow.removeClass("slick-disabled"))),this.setSlideClasses(this.currentSlide)},b.prototype.slideHandler=function(a){var b,c,d=null,e=this;if(b=a,d=-1*b*this.slideWidth+this.slideOffset,c=-1*this.currentSlide*this.slideWidth+this.slideOffset,e.options.autoplay===!0&&clearInterval(this.autoPlayTimer),this.currentLeft=null===this.swipeLeft?c:this.swipeLeft,0>b){if(this.options.infinite!==!0)return this.animateSlide(c),!1;this.animating=!0,this.animateSlide(d,function(){e.postSlide(e.slideCount-e.options.slidesToScroll)})}else if(b>this.slideCount-1){if(this.options.infinite!==!0)return this.animateSlide(c),!1;this.animating=!0,this.animateSlide(d,function(){e.postSlide(0)})}else this.animating=!0,this.animateSlide(d,function(){e.postSlide(b)})},b.prototype.swipeHandler=function(a){var c,b={},d=null;switch(c=-1*this.currentSlide*this.slideWidth+this.slideOffset,"touch"==a.data.kind&&(this.touchObject.fingerCount=a.originalEvent.touches.length),this.touchObject.minSwipe=this.slideWidth/this.options.touchThreshold,a.data.action){case"start":1===this.touchObject.fingerCount||"drag"==a.data.kind?"touch"==a.data.kind?(this.touchObject.startX=a.originalEvent.touches[0].pageX,this.touchObject.startY=a.originalEvent.touches[0].pageY,this.touchObject.curX=a.originalEvent.touches[0].pageX,this.touchObject.curY=a.originalEvent.touches[0].pageY):(this.list.addClass("dragging"),this.touchObject.startX=a.clientX,this.touchObject.startY=a.clientY,this.touchObject.curX=a.clientX,this.touchObject.curY=a.clientY):this.touchObject={};break;case"move":a.originalEvent.touches&&1===a.originalEvent.touches.length||"drag"==a.data.kind?("touch"==a.data.kind?(this.touchObject.curX=a.originalEvent.touches[0].pageX,this.touchObject.curY=a.originalEvent.touches[0].pageY):(this.touchObject.curX=a.clientX,this.touchObject.curY=a.clientY),this.touchObject.swipeLength=Math.round(Math.sqrt(Math.pow(this.touchObject.curX-this.touchObject.startX,2))),"up"!==this.swipeDirection()&&"down"!==this.swipeDirection()&&(a.originalEvent.preventDefault(),this.touchObject.curX>this.touchObject.startX?this.options.touchMove===!0&&(d=c+this.touchObject.swipeLength,this.transformsEnabled===!1?this.slideTrack.css("left",d):(b[this.animType]="translate("+d+"px, 0px)",this.slideTrack.css(b),this.swipeLeft=d)):this.options.touchMove===!0&&(d=c-this.touchObject.swipeLength,this.transformsEnabled===!1?this.slideTrack.css("left",d):(b[this.animType]="translate("+d+"px, 0px)",this.slideTrack.css(b),this.swipeLeft=d)))):this.touchObject={};break;case"end":if(0===this.touchObject.fingerCount&&0!==this.touchObject.curX||"drag"==a.data.kind){if(this.touchObject.swipeLength>=this.touchObject.minSwipe)switch(this.swipeDirection()){case"left":this.slideHandler(this.currentSlide+this.options.slidesToScroll),this.touchObject={};break;case"right":this.slideHandler(this.currentSlide-this.options.slidesToScroll),this.touchObject={}}else this.slideHandler(this.currentSlide),this.touchObject={};"drag"==a.data.kind&&this.list.removeClass("dragging")}else this.touchObject={};break;case"cancel":this.list.removeClass("dragging"),this.touchObject.startX&&(this.slideHandler(this.currentSlide),this.touchObject={})}},b.prototype.swipeDirection=function(){var a,b,c,d;return a=this.touchObject.startX-this.touchObject.curX,b=this.touchObject.startY-this.touchObject.curY,c=Math.atan2(b,a),d=Math.round(180*c/Math.PI),0>d&&(d=360-Math.abs(d)),45>=d&&d>=0?"left":360>=d&&d>=315?"left":d>=135&&225>=d?"right":d>45&&135>d?"down":"up"},b.prototype.refresh=function(){this.destroy(),this.autoPlayTimer=null,this.currentSlide=0,this.currentLeft=null,this.direction=1,this.dots=null,this.listWidth=null,this.loadIndex=0,this.nextArrow=null,this.prevArrow=null,this.slideCount=null,this.slideWidth=null,this.slideTrack=null,this.slides=null,this.sliding=!1,this.slideOffset=0,this.swipeLeft=null,this.list=null,this.touchObject={},this.transformsEnabled=!1,a(this.slider).hasClass("slick-initialized")||(a(this.slider).addClass("slick-initialized"),this.buildOut(),this.setValues(),this.getAnimType(),this.setPosition(),this.startLoad(),this.loadSlider(),this.initializeEvents())},b.prototype.destroy=function(){a(".slick-cloned",this.slider).remove(),a(".slick-placeholder",this.slider).remove(),this.dots&&this.dots.remove(),this.prevArrow&&(this.prevArrow.remove(),this.nextArrow.remove()),this.slides.unwrap().unwrap(),this.slides.removeClass("slick-slide slick-active slick-visible").width(""),this.slider.removeClass("slick-slider"),this.slider.removeClass("slick-initialized")},b}(),a.fn.slick=function(a){return this.each(function(){this.slider=new b.slider(this,a)})},a.fn.unslick=function(){return this.each(function(){this.slider.destroy()})}}); \ No newline at end of file diff --git a/slick.jquery.json b/slick.jquery.json index 8c5bcd231..55d24f4f3 100644 --- a/slick.jquery.json +++ b/slick.jquery.json @@ -9,7 +9,7 @@ "touch", "mobile" ], - "version": "1.0.0", + "version": "1.2.0", "author": { "name": "Ken Wheeler", "url": "http://kenwheeler.github.io" @@ -33,6 +33,6 @@ "docs": "https://github.com/kenwheeler/slick/", "download": "https://github.com/kenwheeler/slick/archive/master.zip", "dependencies": { - "jquery": ">=1.5" + "jquery": ">=1.7" } } \ No newline at end of file diff --git a/slick.js b/slick.js index 5fba7b157..c863d6e46 100644 --- a/slick.js +++ b/slick.js @@ -1,14 +1,9 @@ /* - slick.js - Author: Ken Wheeler Date: 03/23/14 - */ - -/*global window, document, $, setInterval, clearInterval */ - +/*global window, document, define, jQuery, setInterval, clearInterval */ (function (factory) { if (typeof define === 'function' && define.amd) { @@ -19,34 +14,21 @@ }(function ($) { -var slick = window.slick || {}; + var slick = window.slick || {}; -/************ Helpers ***********/ + /************ Helpers ***********/ -// Function Binder + // Function Binder -var functionBinder = function(fn, me) { - 'use strict'; - return function() { - return fn.apply(me, arguments); + var functionBinder = function (fn, me) { + return function () { + return fn.apply(me, arguments); + }; }; -}; - -// Mobile Detect - -var mobileDetect = function() { - var check = false; - (function(a) { - if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) - check = true; - })(navigator.userAgent || navigator.vendor || window.opera); - return check; -}; /********** End Helpers *********/ - slick.slider = (function() { - 'use strict'; + slick.slider = (function () { function slider(element, settings) { @@ -98,28 +80,40 @@ var mobileDetect = function() { this.options = $.extend({}, this.defaults, settings); this.originalSettings = this.options; - var responsiveSettings = this.options.responsive || null; - - if(responsiveSettings && responsiveSettings.length > -1) { - for(var breakpoint in responsiveSettings) { - this.breakpoints.push(responsiveSettings[breakpoint].breakpoint); - this.breakpointSettings[responsiveSettings[breakpoint].breakpoint] = responsiveSettings[breakpoint].settings; + var responsiveSettings = this.options.responsive || + null; + + if (responsiveSettings && responsiveSettings.length > - + 1) { + for (var breakpoint in responsiveSettings) { + this.breakpoints.push(responsiveSettings[ + breakpoint].breakpoint); + this.breakpointSettings[responsiveSettings[ + breakpoint].breakpoint] = + responsiveSettings[breakpoint].settings; } - this.breakpoints.sort(function(a,b){return b-a}); + this.breakpoints.sort(function (a, b) { + return b - a; + }); } - this.changeSlide = functionBinder(this.changeSlide, this); - this.setPosition = functionBinder(this.setPosition, this); - this.swipeHandler = functionBinder(this.swipeHandler, this); - this.dragHandler = functionBinder(this.dragHandler, this); - this.autoPlayIterator = functionBinder(this.autoPlayIterator, this); + this.changeSlide = functionBinder(this.changeSlide, + this); + this.setPosition = functionBinder(this.setPosition, + this); + this.swipeHandler = functionBinder(this.swipeHandler, + this); + this.dragHandler = functionBinder(this.dragHandler, + this); + this.autoPlayIterator = functionBinder(this.autoPlayIterator, + this); this.init(); } - slider.prototype.init = function() { + slider.prototype.init = function () { if (!$(this.slider).hasClass('slick-initialized')) { @@ -136,17 +130,19 @@ var mobileDetect = function() { }; - slider.prototype.getAnimType = function() { + slider.prototype.getAnimType = function () { if (document.body.style.MozTransform !== undefined) { this.animType = 'MozTransform'; - } else if (document.body.style.webkitTransform !== undefined) { + } else if (document.body.style.webkitTransform !== + undefined) { this.animType = "webkitTransform"; - } else if (document.body.style.msTransform !== undefined) { + } else if (document.body.style.msTransform !== + undefined) { this.animType = "msTransform"; @@ -160,7 +156,7 @@ var mobileDetect = function() { }; - slider.prototype.autoPlay = function() { + slider.prototype.autoPlay = function () { if (this.autoPlayTimer) { @@ -168,21 +164,24 @@ var mobileDetect = function() { } - this.autoPlayTimer = setInterval(this.autoPlayIterator, this.options.autoplaySpeed); + this.autoPlayTimer = setInterval(this.autoPlayIterator, + this.options.autoplaySpeed); }; - slider.prototype.autoPlayIterator = function() { + slider.prototype.autoPlayIterator = function () { if (this.options.infinite === false) { if (this.direction === 1) { - if ((this.currentSlide + 1) === this.slideCount - 1) { + if ((this.currentSlide + 1) === this.slideCount - + 1) { this.direction = 0; } - this.slideHandler(this.currentSlide + this.options.slidesToScroll); + this.slideHandler(this.currentSlide + this.options + .slidesToScroll); } else { @@ -192,7 +191,8 @@ var mobileDetect = function() { } - this.slideHandler(this.currentSlide - this.options.slidesToScroll); + this.slideHandler(this.currentSlide - this.options + .slidesToScroll); } @@ -204,34 +204,43 @@ var mobileDetect = function() { }; - slider.prototype.checkResponsive = function() { + slider.prototype.checkResponsive = function () { - if(this.originalSettings.responsive && this.originalSettings.responsive.length > -1) { + if (this.originalSettings.responsive && this.originalSettings + .responsive.length > -1) { var targetBreakpoint = null; - for(var breakpoint in this.breakpoints) { - if($(window).width() < this.breakpoints[breakpoint]) { - targetBreakpoint = this.breakpoints[breakpoint]; + for (var breakpoint in this.breakpoints) { + if ($(window).width() < this.breakpoints[ + breakpoint]) { + targetBreakpoint = this.breakpoints[ + breakpoint]; } } - if(targetBreakpoint !== null) { - if(this.activeBreakpoint !== null) { - if(targetBreakpoint !== this.activeBreakpoint) { - this.activeBreakpoint = targetBreakpoint; - this.options = $.extend({}, this.defaults, this.breakpointSettings[targetBreakpoint]); + if (targetBreakpoint !== null) { + if (this.activeBreakpoint !== null) { + if (targetBreakpoint !== this.activeBreakpoint) { + this.activeBreakpoint = + targetBreakpoint; + this.options = $.extend({}, this.defaults, + this.breakpointSettings[ + targetBreakpoint]); this.refresh(); } } else { this.activeBreakpoint = targetBreakpoint; - this.options = $.extend({}, this.defaults, this.breakpointSettings[targetBreakpoint]); + this.options = $.extend({}, this.defaults, + this.breakpointSettings[ + targetBreakpoint]); this.refresh(); } } else { - if(this.activeBreakpoint !== null) { + if (this.activeBreakpoint !== null) { this.activeBreakpoint = null; - this.options = $.extend({}, this.defaults, this.originalSettings); + this.options = $.extend({}, this.defaults, + this.originalSettings); this.refresh(); } } @@ -239,7 +248,7 @@ var mobileDetect = function() { } }; - slider.prototype.startLoad = function() { + slider.prototype.startLoad = function () { if (this.options.arrows === true) { @@ -258,7 +267,7 @@ var mobileDetect = function() { }; - slider.prototype.loadSlider = function() { + slider.prototype.loadSlider = function () { var self = this; @@ -266,13 +275,13 @@ var mobileDetect = function() { self.slideTrack.animate({ opacity: 1 - }, this.options.speed, function() { + }, this.options.speed, function () { self.setPosition(); }); - if(document.readyState !== "complete") { + if (document.readyState !== "complete") { - $(window).load(function() { + $(window).load(function () { if (self.options.arrows === true) { @@ -324,70 +333,87 @@ var mobileDetect = function() { }; - slider.prototype.setValues = function() { + slider.prototype.setValues = function () { this.listWidth = this.list.innerWidth(); - this.slideWidth = Math.ceil(this.listWidth / this.options.slidesToShow); + this.slideWidth = Math.ceil(this.listWidth / this.options + .slidesToShow); }; - slider.prototype.buildOut = function() { + slider.prototype.buildOut = function () { var i; - this.slides = $(this.options.slide + ':not(.cloned)', this.slider).addClass('slide'); + this.slides = $(this.options.slide + + ':not(.slick-cloned)', this.slider).addClass( + 'slick-slide'); this.slideCount = this.slides.length; - if((this.slideCount % this.options.slidesToScroll) !== 0 && this.options.slidesToShow !== 1) { - - var placeholders = Math.abs(this.options.slidesToScroll - (this.slideCount % this.options.slidesToScroll)); - for(i=0; i').appendTo(this.slider).addClass('slide placeholder'); + if ((this.slideCount % this.options.slidesToScroll) !== + 0 && this.options.slidesToShow !== 1) { + + var placeholders = Math.abs(this.options.slidesToScroll - + (this.slideCount % this.options.slidesToScroll) + ); + for (i = 0; i < placeholders; i++) { + $('
          ').appendTo(this.slider).addClass( + 'slick-slide slick-placeholder'); } - this.slides = $('.slide:not(.cloned)', this.slider); + this.slides = $('.slick-slide:not(.slick-cloned)', + this.slider); this.slideCount = this.slides.length; } this.slider.addClass("slick-slider"); - this.slideTrack = this.slides.wrapAll('
          ').parent(); - this.list = this.slideTrack.wrap('
          ').parent(); + this.slideTrack = this.slides.wrapAll( + '
          ').parent(); + this.list = this.slideTrack.wrap( + '
          ').parent(); this.slideTrack.css('opacity', 0); if (this.options.arrows === true) { - this.prevArrow = $('Previous').appendTo(this.slider).addClass('slick-prev'); - this.nextArrow = $('Next').appendTo(this.slider).addClass('slick-next'); + this.prevArrow = $( + 'Previous').appendTo( + this.slider).addClass('slick-prev'); + this.nextArrow = $( + 'Next').appendTo( + this.slider).addClass('slick-next'); if (this.options.infinite !== true) { - this.prevArrow.addClass('disabled'); + this.prevArrow.addClass('slick-disabled'); } } if (this.options.dots === true) { - this.dots = $('
            ').appendTo(this.slider); + this.dots = $('
              ').appendTo( + this.slider); for (i = 1; i <= this.slideCount; i += 1) { - $('
            • ' + i + '
            • ').appendTo(this.dots); + $('
            • ' + i + + '
            • ').appendTo(this.dots); } - if(this.options.slidesToScroll > 1) { + if (this.options.slidesToScroll > 1) { this.dots.find('li').hide(); - var i = 0; - while(i < this.slideCount) { + i = 0; + while (i < this.slideCount) { $(this.dots.find('li').get(i)).show(); i = i + this.options.slidesToScroll; } } - this.dots.find('li').first().addClass('active'); + this.dots.find('li').first().addClass( + 'slick-active'); } - if (this.options.draggable == true) { + if (this.options.draggable === true) { this.list.addClass('draggable'); } @@ -395,150 +421,171 @@ var mobileDetect = function() { var slideIndex = null; - for(i=this.slideCount; i>(this.slideCount - this.options.slidesToShow); i--) { - slideIndex = i -1; - $(this.slides[slideIndex]).clone().prependTo(this.slideTrack).addClass('cloned'); + for (i = this.slideCount; i > (this.slideCount - + this.options.slidesToShow); i--) { + slideIndex = i - 1; + $(this.slides[slideIndex]).clone().prependTo( + this.slideTrack).addClass('slick-cloned'); } - for(i=0; i= (this.slideCount / + this.options.slidesToScroll * this.options.slidesToShow + ) - this.options.slidesToScroll) { + this.nextArrow.addClass('slick-disabled'); + this.prevArrow.removeClass('slick-disabled'); + } else { + this.prevArrow.removeClass('slick-disabled'); + this.nextArrow.removeClass('slick-disabled'); + } + } + + this.setSlideClasses(this.currentSlide); + + }; + + slider.prototype.slideHandler = function (index) { + + var targetSlide, slideLeft, targetLeft = + null, self = this; targetSlide = index; - targetLeft = ((targetSlide * this.slideWidth) * -1) + this.slideOffset; - slideLeft = ((this.currentSlide * this.slideWidth) * -1) + this.slideOffset; + targetLeft = ((targetSlide * this.slideWidth) * -1) + + this.slideOffset; + slideLeft = ((this.currentSlide * this.slideWidth) * -1) + + this.slideOffset; if (self.options.autoplay === true) { clearInterval(this.autoPlayTimer); @@ -596,32 +702,10 @@ var mobileDetect = function() { this.animating = true; - this.animateSlide(targetLeft, function(){ + this.animateSlide(targetLeft, function () { - self.animating = false; - - self.currentSlide = self.slideCount - self.options.slidesToScroll; - - self.setPosition(); - - if (self.swipeLeft !== null) { - self.swipeLeft = null; - } - - if (self.options.dots) { - self.updateDots(); - } - - if (self.options.autoplay === true) { - self.autoPlay(); - } - - if(self.options.onAfterChange !== null) { - self.options.onAfterChange.call(); - } - - self.slides.removeClass('active'); - $(self.slides.get(targetSlide)).addClass('active'); + self.postSlide(self.slideCount - self.options + .slidesToScroll); }); @@ -639,32 +723,9 @@ var mobileDetect = function() { this.animating = true; - this.animateSlide(targetLeft, function(){ - - self.animating = false; - - self.currentSlide = 0; + this.animateSlide(targetLeft, function () { - self.setPosition(); - - if (self.swipeLeft !== null) { - self.swipeLeft = null; - } - - if (self.options.dots) { - self.updateDots(); - } - - if (self.options.autoplay === true) { - self.autoPlay(); - } - - if(self.options.onAfterChange !== null) { - self.options.onAfterChange.call(); - } - - self.slides.removeClass('active'); - $(self.slides.get(targetSlide)).addClass('active'); + self.postSlide(0); }); @@ -680,45 +741,9 @@ var mobileDetect = function() { this.animating = true; - this.animateSlide(targetLeft, function(){ - - self.animating = false; - - self.currentSlide = targetSlide; - - self.setPosition(); - - if (self.swipeLeft !== null) { - self.swipeLeft = null; - } - - if (self.options.dots) { - self.updateDots(); - } - - if (self.options.autoplay === true) { - self.autoPlay(); - } + this.animateSlide(targetLeft, function () { - if(self.options.onAfterChange !== null) { - self.options.onAfterChange.call(); - } - - self.slides.removeClass('active'); - $(self.slides.get(targetSlide)).addClass('active'); - - if (self.options.arrows === true && self.options.infinite !== true) { - if (self.currentSlide === 0) { - self.prevArrow.addClass('disabled'); - self.nextArrow.removeClass('disabled'); - } else if (self.currentSlide >= (self.slideCount / self.options.slidesToScroll * self.options.slidesToShow) - self.options.slidesToScroll) { - self.nextArrow.addClass('disabled'); - self.prevArrow.removeClass('disabled'); - } else { - self.prevArrow.removeClass('disabled'); - self.nextArrow.removeClass('disabled'); - } - } + self.postSlide(targetSlide); }); @@ -726,48 +751,93 @@ var mobileDetect = function() { }; - slider.prototype.dragHandler = function(event) { + slider.prototype.swipeHandler = function (event) { var animProps = {}, curLeft, newLeft = null; - curLeft = ((this.currentSlide * this.slideWidth) * -1) + this.slideOffset; + curLeft = ((this.currentSlide * this.slideWidth) * -1) + + this.slideOffset; - this.touchObject.minSwipe = this.slideWidth / this.options.touchThreshold; + if (event.data.kind == 'touch') { + this.touchObject.fingerCount = event.originalEvent.touches + .length; + } + + this.touchObject.minSwipe = this.slideWidth / this.options + .touchThreshold; switch (event.data.action) { - case 'start': + case 'start': + + if (this.touchObject.fingerCount === 1 || event.data + .kind == 'drag') { + + if (event.data.kind == 'touch') { + this.touchObject.startX = event.originalEvent + .touches[0].pageX; + this.touchObject.startY = event.originalEvent + .touches[0].pageY; + this.touchObject.curX = event.originalEvent + .touches[0].pageX; + this.touchObject.curY = event.originalEvent + .touches[0].pageY; + } else { + this.list.addClass('dragging'); + this.touchObject.startX = event.clientX; + this.touchObject.startY = event.clientY; + this.touchObject.curX = event.clientX; + this.touchObject.curY = event.clientY; + } + + } else { + this.touchObject = {}; - this.list.addClass('dragging'); + } - this.touchObject.startX = event.clientX; - this.touchObject.startY = event.clientY; - this.touchObject.curX = event.clientX; - this.touchObject.curY = event.clientY; + break; - break; + case 'move': - case 'move': + if ((event.originalEvent.touches && event.originalEvent + .touches.length === 1) || event.data.kind == + 'drag') { - this.touchObject.curX = event.clientX; - this.touchObject.curY = event.clientY; + if (event.data.kind == 'touch') { + this.touchObject.curX = event.originalEvent + .touches[0].pageX; + this.touchObject.curY = event.originalEvent + .touches[0].pageY; + } else { + this.touchObject.curX = event.clientX; + this.touchObject.curY = event.clientY; + } - this.touchObject.swipeLength = Math.round(Math.sqrt(Math.pow(this.touchObject.curX - this.touchObject.startX, 2))); + this.touchObject.swipeLength = Math.round(Math.sqrt( + Math.pow(this.touchObject.curX - this.touchObject + .startX, 2))); - if (this.swipeDirection() !== 'up' && this.swipeDirection() !== 'down') { + if (this.swipeDirection() !== 'up' && this.swipeDirection() !== + 'down') { event.originalEvent.preventDefault(); - if (this.touchObject.curX > this.touchObject.startX) { + if (this.touchObject.curX > this.touchObject + .startX) { - if(this.options.touchMove == true) { + if (this.options.touchMove === true) { - newLeft = curLeft + this.touchObject.swipeLength; - if (this.transformsEnabled === false) { - this.slideTrack.css('left', newLeft); + newLeft = curLeft + this.touchObject + .swipeLength; + if (this.transformsEnabled === + false) { + this.slideTrack.css('left', + newLeft); } else { - animProps[this.animType] = "translate(" + newLeft + "px, 0px)"; + animProps[this.animType] = + "translate(" + newLeft + + "px, 0px)"; this.slideTrack.css(animProps); this.swipeLeft = newLeft; } @@ -776,13 +846,18 @@ var mobileDetect = function() { } else { - if(this.options.touchMove == true) { + if (this.options.touchMove === true) { - newLeft = curLeft - this.touchObject.swipeLength; - if (this.transformsEnabled === false) { - this.slideTrack.css('left', newLeft); + newLeft = curLeft - this.touchObject + .swipeLength; + if (this.transformsEnabled === + false) { + this.slideTrack.css('left', + newLeft); } else { - animProps[this.animType] = "translate(" + newLeft + "px, 0px)"; + animProps[this.animType] = + "translate(" + newLeft + + "px, 0px)"; this.slideTrack.css(animProps); this.swipeLeft = newLeft; } @@ -793,196 +868,77 @@ var mobileDetect = function() { } - break; - - case 'end': - - this.list.removeClass('dragging'); + } else { - if (this.touchObject.curX !== 0) { + this.touchObject = {}; - if (this.touchObject.swipeLength >= this.touchObject.minSwipe) { + } - switch (this.swipeDirection()) { + break; - case 'left': + case 'end': - this.slideHandler(this.currentSlide + this.options.slidesToScroll); - this.touchObject = {}; + if ((this.touchObject.fingerCount === 0 && this.touchObject + .curX !== 0) || event.data.kind == 'drag') { - break; + if (this.touchObject.swipeLength >= this.touchObject + .minSwipe) { - case 'right': + switch (this.swipeDirection()) { - this.slideHandler(this.currentSlide - this.options.slidesToScroll); - this.touchObject = {}; + case 'left': - break; + this.slideHandler(this.currentSlide + + this.options.slidesToScroll); + this.touchObject = {}; - } + break; - } else { + case 'right': - this.slideHandler(this.currentSlide); + this.slideHandler(this.currentSlide - + this.options.slidesToScroll); this.touchObject = {}; + break; + } } else { - this.touchObject = {}; - - } - - break; - - case 'cancel': - - this.list.removeClass('dragging'); - - if(this.touchObject.startX) { this.slideHandler(this.currentSlide); this.touchObject = {}; - } - - break; - - } - - } - - slider.prototype.swipeHandler = function(event) { - - var animProps = {}, curLeft, newLeft = null; - - curLeft = ((this.currentSlide * this.slideWidth) * -1) + this.slideOffset; - - this.touchObject.fingerCount = event.originalEvent.touches.length; - - this.touchObject.minSwipe = this.slideWidth / this.options.touchThreshold; - - switch (event.data.action) { - - case 'start': - - if (this.touchObject.fingerCount === 1) { - - this.touchObject.startX = event.originalEvent.touches[0].pageX; - this.touchObject.startY = event.originalEvent.touches[0].pageY; - this.touchObject.curX = event.originalEvent.touches[0].pageX; - this.touchObject.curY = event.originalEvent.touches[0].pageY; - - } else { - - this.touchObject = {}; } - break; - - case 'move': - - if (event.originalEvent.touches.length === 1) { - - this.touchObject.curX = event.originalEvent.touches[0].pageX; - this.touchObject.curY = event.originalEvent.touches[0].pageY; - - this.touchObject.swipeLength = Math.round(Math.sqrt(Math.pow(this.touchObject.curX - this.touchObject.startX, 2))); - - if (this.swipeDirection() !== 'up' && this.swipeDirection() !== 'down') { - - event.originalEvent.preventDefault(); - - if (this.touchObject.curX > this.touchObject.startX) { - - if(this.options.touchMove == true) { - - newLeft = curLeft + this.touchObject.swipeLength; - if (this.transformsEnabled === false) { - this.slideTrack.css('left', newLeft); - } else { - animProps[this.animType] = "translate(" + newLeft + "px, 0px)"; - this.slideTrack.css(animProps); - this.swipeLeft = newLeft; - } - - } - - } else { - - if(this.options.touchMove == true) { - - newLeft = curLeft - this.touchObject.swipeLength; - if (this.transformsEnabled === false) { - this.slideTrack.css('left', newLeft); - } else { - animProps[this.animType] = "translate(" + newLeft + "px, 0px)"; - this.slideTrack.css(animProps); - this.swipeLeft = newLeft; - } - - } - - } - - } - - } else { - - this.touchObject = {}; - + if (event.data.kind == 'drag') { + this.list.removeClass('dragging'); } - break; - - case 'end': - - if (this.touchObject.fingerCount === 0 && this.touchObject.curX !== 0) { - - if (this.touchObject.swipeLength >= this.touchObject.minSwipe) { - - switch (this.swipeDirection()) { - - case 'left': - - this.slideHandler(this.currentSlide + this.options.slidesToScroll); - this.touchObject = {}; - - break; - - case 'right': - - this.slideHandler(this.currentSlide - this.options.slidesToScroll); - this.touchObject = {}; - - break; - - } - - } else { - - this.slideHandler(this.currentSlide); - this.touchObject = {}; + } else { - } + this.touchObject = {}; - } else { + } - this.touchObject = {}; + break; - } + case 'cancel': - break; + this.list.removeClass('dragging'); - case 'cancel': + if (this.touchObject.startX) { + this.slideHandler(this.currentSlide); + this.touchObject = {}; + } - break; + break; } }; - slider.prototype.swipeDirection = function() { + slider.prototype.swipeDirection = function () { var xDist, yDist, r, swipeAngle; @@ -1009,9 +965,10 @@ var mobileDetect = function() { }; - slider.prototype.refresh = function() { + slider.prototype.refresh = function () { this.destroy(); + this.autoPlayTimer = null; this.currentSlide = 0; this.currentLeft = null; @@ -1035,6 +992,7 @@ var mobileDetect = function() { if (!$(this.slider).hasClass('slick-initialized')) { $(this.slider).addClass('slick-initialized'); + this.buildOut(); this.setValues(); this.getAnimType(); @@ -1045,45 +1003,43 @@ var mobileDetect = function() { } - } + }; - slider.prototype.destroy = function() { - $('.cloned', this.slider).remove(); - $('.placeholder', this.slider).remove(); - if(this.dots) { + slider.prototype.destroy = function () { + $('.slick-cloned', this.slider).remove(); + $('.slick-placeholder', this.slider).remove(); + if (this.dots) { this.dots.remove(); } - if(this.prevArrow) { + if (this.prevArrow) { this.prevArrow.remove(); this.nextArrow.remove(); } this.slides.unwrap().unwrap(); - this.slides.removeClass('slide').width(''); + this.slides.removeClass( + 'slick-slide slick-active slick-visible').width(''); this.slider.removeClass('slick-slider'); this.slider.removeClass('slick-initialized'); - } + }; return slider; }()); -$.fn.slick = function(options) { - - 'use strict'; + $.fn.slick = function (options) { + return this.each(function () { - return this.each(function(index) { + this.slider = new slick.slider(this, options); - this.slider = new slick.slider(this, options); - - }); -} + }); + }; -$.fn.unslick = function(){ - return this.each(function(index) { + $.fn.unslick = function () { + return this.each(function () { - this.slider.destroy(); + this.slider.destroy(); - }); -} + }); + }; })); \ No newline at end of file diff --git a/slick.min.js b/slick.min.js index 36998c1fb..00d0e2eb1 100644 --- a/slick.min.js +++ b/slick.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){var b=window.slick||{},c=function(a,b){"use strict";return function(){return a.apply(b,arguments)}};b.slider=function(){"use strict";function b(b,d){this.defaults={autoplay:!1,autoplaySpeed:3e3,dots:!1,draggable:!0,arrows:!0,infinite:!0,onBeforeChange:null,onAfterChange:null,responsive:null,slide:"div",slidesToShow:1,slidesToScroll:1,speed:300,swipe:!0,touchMove:!0,touchThreshold:5},this.activeBreakpoint=null,this.animating=!1,this.animType=null,this.autoPlayTimer=null,this.breakpoints=[],this.breakpointSettings=[],this.currentSlide=0,this.currentLeft=null,this.direction=1,this.dots=null,this.listWidth=null,this.loadIndex=0,this.nextArrow=null,this.prevArrow=null,this.slideCount=null,this.slideWidth=null,this.slideTrack=null,this.slides=null,this.sliding=!1,this.slideOffset=0,this.slider=a(b),this.swipeLeft=null,this.list=null,this.touchObject={},this.transformsEnabled=!1,this.options=a.extend({},this.defaults,d),this.originalSettings=this.options;var e=this.options.responsive||null;if(e&&e.length>-1){for(var f in e)this.breakpoints.push(e[f].breakpoint),this.breakpointSettings[e[f].breakpoint]=e[f].settings;this.breakpoints.sort(function(a,b){return b-a})}this.changeSlide=c(this.changeSlide,this),this.setPosition=c(this.setPosition,this),this.swipeHandler=c(this.swipeHandler,this),this.dragHandler=c(this.dragHandler,this),this.autoPlayIterator=c(this.autoPlayIterator,this),this.init()}return b.prototype.init=function(){a(this.slider).hasClass("slick-initialized")||(a(this.slider).addClass("slick-initialized"),this.buildOut(),this.setValues(),this.getAnimType(),this.setPosition(),this.startLoad(),this.loadSlider(),this.initializeEvents(),this.checkResponsive())},b.prototype.getAnimType=function(){void 0!==document.body.style.MozTransform?this.animType="MozTransform":void 0!==document.body.style.webkitTransform?this.animType="webkitTransform":void 0!==document.body.style.msTransform&&(this.animType="msTransform"),null!==this.animType&&(this.transformsEnabled=!0)},b.prototype.autoPlay=function(){this.autoPlayTimer&&clearInterval(this.autoPlayTimer),this.autoPlayTimer=setInterval(this.autoPlayIterator,this.options.autoplaySpeed)},b.prototype.autoPlayIterator=function(){this.options.infinite===!1?1===this.direction?(this.currentSlide+1===this.slideCount-1&&(this.direction=0),this.slideHandler(this.currentSlide+this.options.slidesToScroll)):(0===this.currentSlide-1&&(this.direction=1),this.slideHandler(this.currentSlide-this.options.slidesToScroll)):this.slideHandler(this.currentSlide+this.options.slidesToScroll)},b.prototype.checkResponsive=function(){if(this.originalSettings.responsive&&this.originalSettings.responsive.length>-1){var b=null;for(var c in this.breakpoints)a(window).width()b;b++)a("
              ").appendTo(this.slider).addClass("slide placeholder");this.slides=a(".slide:not(.cloned)",this.slider),this.slideCount=this.slides.length}if(this.slider.addClass("slick-slider"),this.slideTrack=this.slides.wrapAll('
              ').parent(),this.list=this.slideTrack.wrap('
              ').parent(),this.slideTrack.css("opacity",0),this.options.arrows===!0&&(this.prevArrow=a('Previous').appendTo(this.slider).addClass("slick-prev"),this.nextArrow=a('Next').appendTo(this.slider).addClass("slick-next"),this.options.infinite!==!0&&this.prevArrow.addClass("disabled")),this.options.dots===!0){for(this.dots=a('
                ').appendTo(this.slider),b=1;b<=this.slideCount;b+=1)a('
              • '+b+"
              • ").appendTo(this.dots);if(this.options.slidesToScroll>1){this.dots.find("li").hide();for(var b=0;bthis.slideCount-this.options.slidesToShow;b--)d=b-1,a(this.slides[d]).clone().prependTo(this.slideTrack).addClass("cloned");for(b=0;bd){if(this.options.infinite!==!0)return this.animateSlide(e),!1;this.animating=!0,this.animateSlide(f,function(){g.animating=!1,g.currentSlide=g.slideCount-g.options.slidesToScroll,g.setPosition(),null!==g.swipeLeft&&(g.swipeLeft=null),g.options.dots&&g.updateDots(),g.options.autoplay===!0&&g.autoPlay(),null!==g.options.onAfterChange&&g.options.onAfterChange.call(),g.slides.removeClass("active"),a(g.slides.get(d)).addClass("active")})}else if(d>this.slideCount-1){if(this.options.infinite!==!0)return this.animateSlide(e),!1;this.animating=!0,this.animateSlide(f,function(){g.animating=!1,g.currentSlide=0,g.setPosition(),null!==g.swipeLeft&&(g.swipeLeft=null),g.options.dots&&g.updateDots(),g.options.autoplay===!0&&g.autoPlay(),null!==g.options.onAfterChange&&g.options.onAfterChange.call(),g.slides.removeClass("active"),a(g.slides.get(d)).addClass("active")})}else this.animating=!0,this.animateSlide(f,function(){g.animating=!1,g.currentSlide=d,g.setPosition(),null!==g.swipeLeft&&(g.swipeLeft=null),g.options.dots&&g.updateDots(),g.options.autoplay===!0&&g.autoPlay(),null!==g.options.onAfterChange&&g.options.onAfterChange.call(),g.slides.removeClass("active"),a(g.slides.get(d)).addClass("active"),g.options.arrows===!0&&g.options.infinite!==!0&&(0===g.currentSlide?(g.prevArrow.addClass("disabled"),g.nextArrow.removeClass("disabled")):g.currentSlide>=g.slideCount/g.options.slidesToScroll*g.options.slidesToShow-g.options.slidesToScroll?(g.nextArrow.addClass("disabled"),g.prevArrow.removeClass("disabled")):(g.prevArrow.removeClass("disabled"),g.nextArrow.removeClass("disabled")))})},b.prototype.dragHandler=function(a){var c,b={},d=null;switch(c=-1*this.currentSlide*this.slideWidth+this.slideOffset,this.touchObject.minSwipe=this.slideWidth/this.options.touchThreshold,a.data.action){case"start":this.list.addClass("dragging"),this.touchObject.startX=a.clientX,this.touchObject.startY=a.clientY,this.touchObject.curX=a.clientX,this.touchObject.curY=a.clientY;break;case"move":this.touchObject.curX=a.clientX,this.touchObject.curY=a.clientY,this.touchObject.swipeLength=Math.round(Math.sqrt(Math.pow(this.touchObject.curX-this.touchObject.startX,2))),"up"!==this.swipeDirection()&&"down"!==this.swipeDirection()&&(a.originalEvent.preventDefault(),this.touchObject.curX>this.touchObject.startX?1==this.options.touchMove&&(d=c+this.touchObject.swipeLength,this.transformsEnabled===!1?this.slideTrack.css("left",d):(b[this.animType]="translate("+d+"px, 0px)",this.slideTrack.css(b),this.swipeLeft=d)):1==this.options.touchMove&&(d=c-this.touchObject.swipeLength,this.transformsEnabled===!1?this.slideTrack.css("left",d):(b[this.animType]="translate("+d+"px, 0px)",this.slideTrack.css(b),this.swipeLeft=d)));break;case"end":if(this.list.removeClass("dragging"),0!==this.touchObject.curX)if(this.touchObject.swipeLength>=this.touchObject.minSwipe)switch(this.swipeDirection()){case"left":this.slideHandler(this.currentSlide+this.options.slidesToScroll),this.touchObject={};break;case"right":this.slideHandler(this.currentSlide-this.options.slidesToScroll),this.touchObject={}}else this.slideHandler(this.currentSlide),this.touchObject={};else this.touchObject={};break;case"cancel":this.list.removeClass("dragging"),this.touchObject.startX&&(this.slideHandler(this.currentSlide),this.touchObject={})}},b.prototype.swipeHandler=function(a){var c,b={},d=null;switch(c=-1*this.currentSlide*this.slideWidth+this.slideOffset,this.touchObject.fingerCount=a.originalEvent.touches.length,this.touchObject.minSwipe=this.slideWidth/this.options.touchThreshold,a.data.action){case"start":1===this.touchObject.fingerCount?(this.touchObject.startX=a.originalEvent.touches[0].pageX,this.touchObject.startY=a.originalEvent.touches[0].pageY,this.touchObject.curX=a.originalEvent.touches[0].pageX,this.touchObject.curY=a.originalEvent.touches[0].pageY):this.touchObject={};break;case"move":1===a.originalEvent.touches.length?(this.touchObject.curX=a.originalEvent.touches[0].pageX,this.touchObject.curY=a.originalEvent.touches[0].pageY,this.touchObject.swipeLength=Math.round(Math.sqrt(Math.pow(this.touchObject.curX-this.touchObject.startX,2))),"up"!==this.swipeDirection()&&"down"!==this.swipeDirection()&&(a.originalEvent.preventDefault(),this.touchObject.curX>this.touchObject.startX?1==this.options.touchMove&&(d=c+this.touchObject.swipeLength,this.transformsEnabled===!1?this.slideTrack.css("left",d):(b[this.animType]="translate("+d+"px, 0px)",this.slideTrack.css(b),this.swipeLeft=d)):1==this.options.touchMove&&(d=c-this.touchObject.swipeLength,this.transformsEnabled===!1?this.slideTrack.css("left",d):(b[this.animType]="translate("+d+"px, 0px)",this.slideTrack.css(b),this.swipeLeft=d)))):this.touchObject={};break;case"end":if(0===this.touchObject.fingerCount&&0!==this.touchObject.curX)if(this.touchObject.swipeLength>=this.touchObject.minSwipe)switch(this.swipeDirection()){case"left":this.slideHandler(this.currentSlide+this.options.slidesToScroll),this.touchObject={};break;case"right":this.slideHandler(this.currentSlide-this.options.slidesToScroll),this.touchObject={}}else this.slideHandler(this.currentSlide),this.touchObject={};else this.touchObject={};break;case"cancel":}},b.prototype.swipeDirection=function(){var a,b,c,d;return a=this.touchObject.startX-this.touchObject.curX,b=this.touchObject.startY-this.touchObject.curY,c=Math.atan2(b,a),d=Math.round(180*c/Math.PI),0>d&&(d=360-Math.abs(d)),45>=d&&d>=0?"left":360>=d&&d>=315?"left":d>=135&&225>=d?"right":d>45&&135>d?"down":"up"},b.prototype.refresh=function(){this.destroy(),this.autoPlayTimer=null,this.currentSlide=0,this.currentLeft=null,this.direction=1,this.dots=null,this.listWidth=null,this.loadIndex=0,this.nextArrow=null,this.prevArrow=null,this.slideCount=null,this.slideWidth=null,this.slideTrack=null,this.slides=null,this.sliding=!1,this.slideOffset=0,this.swipeLeft=null,this.list=null,this.touchObject={},this.transformsEnabled=!1,a(this.slider).hasClass("slick-initialized")||(a(this.slider).addClass("slick-initialized"),this.buildOut(),this.setValues(),this.getAnimType(),this.setPosition(),this.startLoad(),this.loadSlider(),this.initializeEvents())},b.prototype.destroy=function(){a(".cloned",this.slider).remove(),a(".placeholder",this.slider).remove(),this.dots&&this.dots.remove(),this.prevArrow&&(this.prevArrow.remove(),this.nextArrow.remove()),this.slides.unwrap().unwrap(),this.slides.removeClass("slide").width(""),this.slider.removeClass("slick-slider"),this.slider.removeClass("slick-initialized")},b}(),a.fn.slick=function(a){"use strict";return this.each(function(){this.slider=new b.slider(this,a)})},a.fn.unslick=function(){return this.each(function(){this.slider.destroy()})}}); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){var b=window.slick||{},c=function(a,b){return function(){return a.apply(b,arguments)}};b.slider=function(){function b(b,d){this.defaults={autoplay:!1,autoplaySpeed:3e3,dots:!1,draggable:!0,arrows:!0,infinite:!0,onBeforeChange:null,onAfterChange:null,responsive:null,slide:"div",slidesToShow:1,slidesToScroll:1,speed:300,swipe:!0,touchMove:!0,touchThreshold:5},this.activeBreakpoint=null,this.animating=!1,this.animType=null,this.autoPlayTimer=null,this.breakpoints=[],this.breakpointSettings=[],this.currentSlide=0,this.currentLeft=null,this.direction=1,this.dots=null,this.listWidth=null,this.loadIndex=0,this.nextArrow=null,this.prevArrow=null,this.slideCount=null,this.slideWidth=null,this.slideTrack=null,this.slides=null,this.sliding=!1,this.slideOffset=0,this.slider=a(b),this.swipeLeft=null,this.list=null,this.touchObject={},this.transformsEnabled=!1,this.options=a.extend({},this.defaults,d),this.originalSettings=this.options;var e=this.options.responsive||null;if(e&&e.length>-1){for(var f in e)this.breakpoints.push(e[f].breakpoint),this.breakpointSettings[e[f].breakpoint]=e[f].settings;this.breakpoints.sort(function(a,b){return b-a})}this.changeSlide=c(this.changeSlide,this),this.setPosition=c(this.setPosition,this),this.swipeHandler=c(this.swipeHandler,this),this.dragHandler=c(this.dragHandler,this),this.autoPlayIterator=c(this.autoPlayIterator,this),this.init()}return b.prototype.init=function(){a(this.slider).hasClass("slick-initialized")||(a(this.slider).addClass("slick-initialized"),this.buildOut(),this.setValues(),this.getAnimType(),this.setPosition(),this.startLoad(),this.loadSlider(),this.initializeEvents(),this.checkResponsive())},b.prototype.getAnimType=function(){void 0!==document.body.style.MozTransform?this.animType="MozTransform":void 0!==document.body.style.webkitTransform?this.animType="webkitTransform":void 0!==document.body.style.msTransform&&(this.animType="msTransform"),null!==this.animType&&(this.transformsEnabled=!0)},b.prototype.autoPlay=function(){this.autoPlayTimer&&clearInterval(this.autoPlayTimer),this.autoPlayTimer=setInterval(this.autoPlayIterator,this.options.autoplaySpeed)},b.prototype.autoPlayIterator=function(){this.options.infinite===!1?1===this.direction?(this.currentSlide+1===this.slideCount-1&&(this.direction=0),this.slideHandler(this.currentSlide+this.options.slidesToScroll)):(0===this.currentSlide-1&&(this.direction=1),this.slideHandler(this.currentSlide-this.options.slidesToScroll)):this.slideHandler(this.currentSlide+this.options.slidesToScroll)},b.prototype.checkResponsive=function(){if(this.originalSettings.responsive&&this.originalSettings.responsive.length>-1){var b=null;for(var c in this.breakpoints)a(window).width()b;b++)a("
                ").appendTo(this.slider).addClass("slick-slide slick-placeholder");this.slides=a(".slick-slide:not(.slick-cloned)",this.slider),this.slideCount=this.slides.length}if(this.slider.addClass("slick-slider"),this.slideTrack=this.slides.wrapAll('
                ').parent(),this.list=this.slideTrack.wrap('
                ').parent(),this.slideTrack.css("opacity",0),this.options.arrows===!0&&(this.prevArrow=a('Previous').appendTo(this.slider).addClass("slick-prev"),this.nextArrow=a('Next').appendTo(this.slider).addClass("slick-next"),this.options.infinite!==!0&&this.prevArrow.addClass("slick-disabled")),this.options.dots===!0){for(this.dots=a('
                  ').appendTo(this.slider),b=1;b<=this.slideCount;b+=1)a('
                • '+b+"
                • ").appendTo(this.dots);if(this.options.slidesToScroll>1)for(this.dots.find("li").hide(),b=0;bthis.slideCount-this.options.slidesToShow;b--)d=b-1,a(this.slides[d]).clone().prependTo(this.slideTrack).addClass("slick-cloned");for(b=0;bd;d++)a(this.slides.get(d)).addClass("slick-visible")},b.prototype.postSlide=function(a){this.animating=!1,this.currentSlide=a,this.setPosition(),null!==this.swipeLeft&&(this.swipeLeft=null),this.options.dots&&this.updateDots(),this.options.autoplay===!0&&this.autoPlay(),null!==this.options.onAfterChange&&this.options.onAfterChange.call(),this.options.arrows===!0&&this.options.infinite!==!0&&(0===this.currentSlide?(this.prevArrow.addClass("slick-disabled"),this.nextArrow.removeClass("slick-disabled")):this.currentSlide>=this.slideCount/this.options.slidesToScroll*this.options.slidesToShow-this.options.slidesToScroll?(this.nextArrow.addClass("slick-disabled"),this.prevArrow.removeClass("slick-disabled")):(this.prevArrow.removeClass("slick-disabled"),this.nextArrow.removeClass("slick-disabled"))),this.setSlideClasses(this.currentSlide)},b.prototype.slideHandler=function(a){var b,c,d=null,e=this;if(b=a,d=-1*b*this.slideWidth+this.slideOffset,c=-1*this.currentSlide*this.slideWidth+this.slideOffset,e.options.autoplay===!0&&clearInterval(this.autoPlayTimer),this.currentLeft=null===this.swipeLeft?c:this.swipeLeft,0>b){if(this.options.infinite!==!0)return this.animateSlide(c),!1;this.animating=!0,this.animateSlide(d,function(){e.postSlide(e.slideCount-e.options.slidesToScroll)})}else if(b>this.slideCount-1){if(this.options.infinite!==!0)return this.animateSlide(c),!1;this.animating=!0,this.animateSlide(d,function(){e.postSlide(0)})}else this.animating=!0,this.animateSlide(d,function(){e.postSlide(b)})},b.prototype.swipeHandler=function(a){var c,b={},d=null;switch(c=-1*this.currentSlide*this.slideWidth+this.slideOffset,"touch"==a.data.kind&&(this.touchObject.fingerCount=a.originalEvent.touches.length),this.touchObject.minSwipe=this.slideWidth/this.options.touchThreshold,a.data.action){case"start":1===this.touchObject.fingerCount||"drag"==a.data.kind?"touch"==a.data.kind?(this.touchObject.startX=a.originalEvent.touches[0].pageX,this.touchObject.startY=a.originalEvent.touches[0].pageY,this.touchObject.curX=a.originalEvent.touches[0].pageX,this.touchObject.curY=a.originalEvent.touches[0].pageY):(this.list.addClass("dragging"),this.touchObject.startX=a.clientX,this.touchObject.startY=a.clientY,this.touchObject.curX=a.clientX,this.touchObject.curY=a.clientY):this.touchObject={};break;case"move":a.originalEvent.touches&&1===a.originalEvent.touches.length||"drag"==a.data.kind?("touch"==a.data.kind?(this.touchObject.curX=a.originalEvent.touches[0].pageX,this.touchObject.curY=a.originalEvent.touches[0].pageY):(this.touchObject.curX=a.clientX,this.touchObject.curY=a.clientY),this.touchObject.swipeLength=Math.round(Math.sqrt(Math.pow(this.touchObject.curX-this.touchObject.startX,2))),"up"!==this.swipeDirection()&&"down"!==this.swipeDirection()&&(a.originalEvent.preventDefault(),this.touchObject.curX>this.touchObject.startX?this.options.touchMove===!0&&(d=c+this.touchObject.swipeLength,this.transformsEnabled===!1?this.slideTrack.css("left",d):(b[this.animType]="translate("+d+"px, 0px)",this.slideTrack.css(b),this.swipeLeft=d)):this.options.touchMove===!0&&(d=c-this.touchObject.swipeLength,this.transformsEnabled===!1?this.slideTrack.css("left",d):(b[this.animType]="translate("+d+"px, 0px)",this.slideTrack.css(b),this.swipeLeft=d)))):this.touchObject={};break;case"end":if(0===this.touchObject.fingerCount&&0!==this.touchObject.curX||"drag"==a.data.kind){if(this.touchObject.swipeLength>=this.touchObject.minSwipe)switch(this.swipeDirection()){case"left":this.slideHandler(this.currentSlide+this.options.slidesToScroll),this.touchObject={};break;case"right":this.slideHandler(this.currentSlide-this.options.slidesToScroll),this.touchObject={}}else this.slideHandler(this.currentSlide),this.touchObject={};"drag"==a.data.kind&&this.list.removeClass("dragging")}else this.touchObject={};break;case"cancel":this.list.removeClass("dragging"),this.touchObject.startX&&(this.slideHandler(this.currentSlide),this.touchObject={})}},b.prototype.swipeDirection=function(){var a,b,c,d;return a=this.touchObject.startX-this.touchObject.curX,b=this.touchObject.startY-this.touchObject.curY,c=Math.atan2(b,a),d=Math.round(180*c/Math.PI),0>d&&(d=360-Math.abs(d)),45>=d&&d>=0?"left":360>=d&&d>=315?"left":d>=135&&225>=d?"right":d>45&&135>d?"down":"up"},b.prototype.refresh=function(){this.destroy(),this.autoPlayTimer=null,this.currentSlide=0,this.currentLeft=null,this.direction=1,this.dots=null,this.listWidth=null,this.loadIndex=0,this.nextArrow=null,this.prevArrow=null,this.slideCount=null,this.slideWidth=null,this.slideTrack=null,this.slides=null,this.sliding=!1,this.slideOffset=0,this.swipeLeft=null,this.list=null,this.touchObject={},this.transformsEnabled=!1,a(this.slider).hasClass("slick-initialized")||(a(this.slider).addClass("slick-initialized"),this.buildOut(),this.setValues(),this.getAnimType(),this.setPosition(),this.startLoad(),this.loadSlider(),this.initializeEvents())},b.prototype.destroy=function(){a(".slick-cloned",this.slider).remove(),a(".slick-placeholder",this.slider).remove(),this.dots&&this.dots.remove(),this.prevArrow&&(this.prevArrow.remove(),this.nextArrow.remove()),this.slides.unwrap().unwrap(),this.slides.removeClass("slick-slide slick-active slick-visible").width(""),this.slider.removeClass("slick-slider"),this.slider.removeClass("slick-initialized")},b}(),a.fn.slick=function(a){return this.each(function(){this.slider=new b.slider(this,a)})},a.fn.unslick=function(){return this.each(function(){this.slider.destroy()})}}); \ No newline at end of file