bradbirdsall/Swipe — pull request #170 by andyburke (2013-01-12 01:44:10+00:00)
Title: Add EventEmitter support and an option for looping...

Hey,

This change adds support for EventEmitter by @Wolfy87 (https://github.com/Wolfy87/EventEmitter). Eg:

var swipe = new Swipe(document.getElementById('slider'));
swipe.events.on( 'next', function() {
console.log( 'attempting to move to next slide' );
});

swipe.events.on( 'prev', function() {
console.log( 'attempting to move to previous slide' );
});

swipe.events.on( 'slide', function( index, slide ) {
console.log( 'moving to slide index: ' + index );
});

swipe.events.on( 'transitioned', function( index, slide ) {
console.log( 'transitioned to slide index: ' + index );
});

swipe.events.on( 'begin', function() {
console.log( 'beginning auto sliding' );
});

swipe.events.on( 'stop', function() {
console.log( 'stopping auto sliding' );
});

swipe.events.on( 'resume', function() {
console.log( 'resuming auto sliding' );
});

It also adds an option to control if the slider should loop. Eg:

var swipe = new Swipe(document.getElementById('slider'), {
looping: false // will not loop on next/prev calls at last/first slide
});

Let me know what you think. I'm open to making changes if this doesn't quite meet your expectations.