jQuery bug on animate() function???
Hi everybody:
I'm a newbie with jQuery trying to write a plugin and have som problems with the animate function.
I've developed a Mootools plugin and now I'm trying to port it to jQuery.
The fact is that I want to move a div from the bottom of a document, but it has a weird behaviour in
Firefox (it works well on Internet Explorer 7).
This is the code for the html test page:
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery test page</title>
<script type="text/javascript" src="js/jquery/jquery-1.3.2-clean.js"></script>
<script type="text/javascript" src="js/test.js"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</head>
<body style="height: 700px;">
<h1>Test page checking jQuery animate function</h1>
<br/>
<a id="testLink" href="#">Click to move the panel</a>
</body>
</html>
and here is the jQuery code:
-
$(document).ready(function() {
var $el = $('<div id="testPanel"></div>');
$el.css({
width: 200,
height: 100,
position: 'absolute',
bottom: 0,
marginBottom: 10,
backgroundColor: 'black'
});
$('body').append($el);
$('#testLink').click(function(){
$('#testPanel').animate({bottom: 150}, 2000, 'linear');
return false;
});
});
The problem is that animate() function does not get the correct current position so it starts the effect from a wrong place.
In jQuery js file (line 3906) there is this code:
-
var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
start = e.cur(true) || 0;
If I change the current position function call to be like:
-
start = e.cur(false) || 0;
it works well.
So, is there a bug in the code or am I doing something else wrong?
Thanks in advance.