
Untitled
By: a guest on
Aug 11th, 2012 | syntax:
None | size: 1.23 KB | hits: 4 | expires: Never
How do I use the properties created by an animate function in that animate function's callback?
<script type="text/javascript">
$(document).ready(function(){
$(".ExampleImage").toggle(
function(){
var Image = $(this);
var Container = $(this).closest(".ImageContainer");
Image.switchClass("ExampleImageContracted","ExampleImageExpanded",500);
Container.css('height','auto');
Image.queue(scrollToExample(Image));
},
function(){
var Image = $(this);
var Container = $(this).closest(".ImageContainer");
Image.switchClass("ExampleImageExpanded","ExampleImageContracted",500);
Container.animate({'height':'250'},500,scrollToExample(Image));
}
);
function scrollToExample(Image) {
var NewTop = $(Image).closest(".Example").offset();
$('html, body').animate( {
scrollTop:NewTop.top
}, 1000);
}
});
</script>
Image.queue(scrollToExample(Image));
...
Container.animate({'height':'250'},500,scrollToExample(Image));
Image.queue(function() { scrollToExample(Image); });
...
Container.animate({'height':'250'},500,function(){scrollToExample(Image);});