Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
jquery -10000px bug
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>jQuery.animate 10000px bug</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script>
/**
* I'm trying to animate and change margin-left property of an element
* It works fine under -10000px but it doesnt work >= -10000
*
* There's a div#bug container which has a red border, and overflow:hidden
* and a div.inner which has width over -10000px
*
* when i try to animet with margin-left: -10000 i saw TextTextText
* but when tried with margin-left: -99999 it works fine
*/
$(document).ready( function(){
var inner = $("#bug .inner");
$("#marginLeft").click( function(){
inner.animate({
"margin-left": "-10000px" //i see TextTextText on every click
// "margin-left": "-10000" //this doesnt work either
// "margin-left": "-9999" //but its not repreduced below 10000px
}, 1000, function() {
});
});
});
</script>
</head>
<body>
<div id="bug" style="width:500px; border:1px dotted #FF0000; overflow:hidden">
<div class="inner" style="width:12000px">
TextTextText
</div> <!-- .inner -->
</div> <!-- #bug -->
<a id="marginLeft" href="#">Animate</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment