Skip to content

Commit

Permalink
Adding auto play stop on hover & methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kenwheeler committed Mar 29, 2014
1 parent 8a9a420 commit a139e26
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "slick-carousel",
"main": "slick.js",
"version": "1.2.4",
"version": "1.2.5",
"homepage": "https://github.com/kenwheeler/slick",
"authors": [
"Ken Wheeler <[email protected]>"
Expand Down
58 changes: 57 additions & 1 deletion js/slick.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
infinite: true,
onBeforeChange: null,
onAfterChange: null,
pauseOnHover: true,
responsive: null,
slide: 'div',
slidesToShow: 1,
Expand Down Expand Up @@ -105,6 +106,10 @@
});
}

_.autoPlay = functionBinder(_.autoPlay,
_);
_.autoPlayClear = functionBinder(_.autoPlayClear,
_);
_.changeSlide = functionBinder(_.changeSlide,
_);
_.setPosition = functionBinder(_.setPosition,
Expand Down Expand Up @@ -184,6 +189,16 @@

};

Slick.prototype.autoPlayClear = function () {

var _ = this;

if (_.autoPlayTimer) {
clearInterval(_.autoPlayTimer);
}

};

Slick.prototype.autoPlayIterator = function () {

var _ = this;
Expand Down Expand Up @@ -566,6 +581,11 @@
}, _.swipeHandler);
}

if (_.options.pauseOnHover === true && _.options.autoplay === true) {
_.list.on('mouseenter.slick', _.autoPlayClear);
_.list.on('mouseleave.slick', _.autoPlay);
}

$(window).on('orientationchange.slick', _.setPosition);

$(window).on('resize.slick', function () {
Expand Down Expand Up @@ -1070,7 +1090,7 @@
});
};

$.fn.changeSlickSlide = function (slide) {
$.fn.slickGoTo = function (slide) {
var _ = this;
return _.each(function (index, element) {

Expand All @@ -1079,6 +1099,42 @@
});
};

$.fn.slickNext = function () {
var _ = this;
return _.each(function (index, element) {

element.slick.changeSlide({data: {message: 'next'}});

});
};

$.fn.slickPrev = function () {
var _ = this;
return _.each(function (index, element) {

element.slick.changeSlide({data: {message: 'previous'}});

});
};

$.fn.slickPause = function () {
var _ = this;
return _.each(function (index, element) {

element.slick.autoPlayClear();

});
};

$.fn.slickPlay = function () {
var _ = this;
return _.each(function (index, element) {

element.slick.autoPlay();

});
};

$.fn.unslick = function () {
var _ = this;
return _.each(function (index, element) {
Expand Down
Loading

0 comments on commit a139e26

Please sign in to comment.