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

Added slidechange event & a few methods which may or may not be useful... #119

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
54 changes: 49 additions & 5 deletions js/bjqs-1.3.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,35 @@
$slider.show();
$slides.eq(state.currentindex).show();

// Finally, if automatic is set to true, kick off the interval
// Finally, if automatic is set to true, play
if(settings.automatic){
state.interval = setInterval(function () {
play( false );
}

};

var play = function( immediate ) {
// if there's an interval already set, bail
if( state.interval !== null ) return;

// kick off the interval
state.interval = setInterval(function () {
go(vars.fwd, false);
}, settings.animspeed);
}

// start immediately if we've been asked
if( immediate ) go(vars.fwd, false);
};
// public accessor
$wrapper.play = play;

var stop = function()
{
clearInterval( state.interval );
state.interval = null;
};
// public accessor
$wrapper.stop = stop;

var conf_responsive = function() {

Expand Down Expand Up @@ -630,6 +651,8 @@
set_next(direction);
}

var outgoingindex = state.currentindex-1;

// fade animation
if(settings.animtype === 'fade'){

Expand All @@ -648,6 +671,10 @@
state.currentslide = state.nextslide;
state.currentindex = state.nextindex;

// emit slide change event
var e = jQuery.Event( "slidechange", { outgoingindex: outgoingindex, incomingindex: state.currentindex-1 } );
$wrapper.trigger( e );

});

}
Expand Down Expand Up @@ -703,14 +730,31 @@

state.animating = false;

// emit slide change event
var e = jQuery.Event( "slidechange", { outgoingindex: outgoingindex, incomingindex: state.currentindex-1 } );
$wrapper.trigger( e );

});

}

}

};

$wrapper.toggleControls = function( show, duration ) {
if( !duration && duration !== 0 ) duration = defaults.animduration;
$c_fwd = $wrapper.find( "li.bjqs-next a" );
$c_prev = $wrapper.find( "li.bjqs-prev a" );
if( $c_fwd.length > 0 && $c_prev.length > 0 ){
if( show ) {
$c_fwd.fadeIn( duration );
$c_prev.fadeIn( duration );
} else {
$c_fwd.fadeOut( duration );
$c_prev.fadeOut( duration );
}
}
};

// lets get the party started :)
init();

Expand Down