
Untitled
By: a guest on
Apr 29th, 2012 | syntax:
None | size: 1.02 KB | hits: 21 | expires: Never
jQuery animate being shaky
jQuery.fn.extend({
letsTravel: function() {
var horizontalRange = jQuery(this).width() - jQuery(this).parent().width();
var verticalRange = jQuery(this).height() - jQuery(this).parent().height();
var halfHeight = div(verticalRange,2);
//horizontalRange and verticalRange are maximum valid horizontal/vertical offset
//all coordinates should be below 0 because start point is 0,0
jQuery(this).animate({left: (horizontalRange-120)*(-1), top: halfHeight*(-1)},20000, 'linear', function(){
jQuery(this).animate({left: horizontalRange*(-1), top: verticalRange*(-1)},20000, 'linear', function(){
jQuery(this).animate({left: (horizontalRange/2)*(-1)},10000, 'linear', function(){
jQuery(this).animate({left: 0, top: halfHeight*(-1)},20000, 'linear', function(){
jQuery(this).animate({top: 0},10000, 'linear');
});
});
});
});
}
});