Created
October 20, 2009 13:31
-
-
Save jakearchibald/214260 to your computer and use it in GitHub Desktop.
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
function slideRight(elm, seconds, opts) { | |
elm = glow.dom.get(elm); | |
opts = opts || {}; | |
// make the tween easeBoth by default | |
opts.tween = opts.tween || glow.tweens.easeBoth(); | |
// get the full width of the item | |
var currentWidth = elm[0].style.width, | |
fullWidth, | |
anim; | |
elm[0].style.width = ''; | |
fullWidth = elm.css('width'); | |
elm[0].style.width = currentWidth; | |
anim = glow.anim.css(elm, seconds, { | |
width: fullWidth | |
}, opts); | |
// unset the width when the anim completes, needed for relative widths (so they resize) | |
glow.events.addListener(anim, 'complete', function() { | |
elm[0].style.width = ''; | |
}); | |
// make the animation | |
return anim.start(); | |
} | |
function slideLeft(elm, seconds, opts) { | |
elm = glow.dom.get(elm); | |
opts = opts || {}; | |
// make the tween easeBoth by default | |
opts.tween = opts.tween || glow.tweens.easeBoth(); | |
// make the animation | |
return glow.anim.css(elm, seconds, { | |
width: 0 | |
}, opts).start(); | |
} | |
// usage: | |
// You can use CSS selectors or NodeLists to animate | |
slideLeft('#elementToAnimate', 3); | |
slideRight('#elementToAnimate', 3); | |
// You can give it the same options as http://www.bbc.co.uk/glow/docs/1.7/api/glow.anim.shtml#staticmethod:css | |
slideLeft('#elementToAnimate', 1, { | |
onComplete: function() { | |
alert("I've completed!"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment