Created
September 29, 2008 20:56
-
-
Save swannodette/13673 to your computer and use it in GitHub Desktop.
Rodrigo's code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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