Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds play and pause buttons. user must create markup. tweaked from http:... #314

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions responsiveslides.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
fadeTime = parseFloat(settings.speed),
waitTime = parseFloat(settings.timeout),
maxw = parseFloat(settings.maxwidth),
forcePause = false,

// Namespacing
namespace = settings.namespace,
Expand Down Expand Up @@ -92,7 +93,7 @@
})(),

// Fading animation
slideTo = function (idx) {
slideTo = function (idx) {
settings.before(idx);
// If CSS3 transitions are supported
if (supportsTransitions) {
Expand All @@ -102,7 +103,7 @@
.eq(idx)
.addClass(visibleClass)
.css(visible);
index = idx;
index = idx;
setTimeout(function () {
settings.after(idx);
}, fadeTime);
Expand Down Expand Up @@ -213,7 +214,7 @@

// If we have a pager, we need to set up the selectTab function
if (settings.pager || settings.manualControls) {
$tabs = $pager.find('a');
$tabs = $pager.find("a");

// Select pager item
selectTab = function (idx) {
Expand Down Expand Up @@ -254,8 +255,10 @@
if (settings.auto) {
// Stop
clearInterval(rotate);
// Restart
startCycle();
if ( !forcePause ) {
// Restart
startCycle();
}
}
};

Expand All @@ -281,7 +284,7 @@
var idx = $tabs.index(this);

// Break if element is already active or currently animated
if (index === idx || $("." + visibleClass).queue('fx').length) {
if (index === idx || $("." + visibleClass).queue("fx").length) {
return;
}

Expand All @@ -295,6 +298,22 @@
.closest("li")
.addClass(activeClass);

$( ".pause_slider" ).click( function( e ){
e.preventDefault();
forcePause = true;
$( this ).hide();
$( ".play_slider" ).show();
clearInterval(rotate);
});

$( ".play_slider" ).click( function( e ) {
e.preventDefault();
forcePause = false;
$( this ).hide();
$( ".pause_slider" ).show();
restartCycle();
});

// Pause when hovering pager
if (settings.pauseControls) {
$tabs.hover(function () {
Expand Down Expand Up @@ -328,7 +347,7 @@
var $visibleClass = $("." + visibleClass);

// Prevent clicking if currently animated
if ($visibleClass.queue('fx').length) {
if ($visibleClass.queue("fx").length) {
return;
}

Expand Down