Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created September 29, 2008 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swannodette/13673 to your computer and use it in GitHub Desktop.
Save swannodette/13673 to your computer and use it in GitHub Desktop.
Rodrigo's code
var MySliderClass = new Class({
Implements: Chain,
initialize: function (element)
{
this.element = $(element);
},
prepareSlide: function(prop, pos0, pos1)
{
this.element.set('tween', {
duration : 1000,
transition : Fx.Transitions.Cubic.easeInOut,
onComplete: this.slide.bind(this) // at the end of the animation call the slide method
});
// add this to the chain
this.chain(function() {
// need to bind this, use closures to call the tween w/ the right properties
this.element.tween(prop, [pos0, pos1]);
}.bind(this));
},
slide: function()
{
// kick of the chain
this.callChain();
}
});
var mySlider;
function init()
{
mySlider = new MySliderClass($('quad'));
// prepare the sliding animations
mySlider.prepareSlide('left', 0, 400);
mySlider.prepareSlide('top', 0, 200);
mySlider.prepareSlide('left', 400, 0);
mySlider.prepareSlide('top', 200, 0);
// start
mySlider.slide();
}
window.addEvent('domready', init);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment