#8834 closed bug (invalid)
Bug in offset changing in chrome during zoom
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | 1.next |
Component: | unfiled | Version: | 1.5.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In chrome, changing element's offset during zoom out is buggy. For example, the following code which suppose to move a box one pixel right and one pixel down, doesn't work well when chrome is zoomed out:
<html> <head>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.5.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#button1").click(function () {
$("#box").offset({
top: $("#box").offset().top + 1, left: $("#box").offset().left + 1
});
$("#boxLocation").text($("#box").offset().top + "," + $("#box").offset().left);
});
});
</script>
</head> <body>
<div id="box" style="position:absolute; width: 100px; height:100px; left: 300; top:300; background-color:Red;"></div> <button id="button1">Test</button> Box location: <span id="boxLocation"></span>
</body> </html>
Change History (3)
comment:1 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 Changed 12 years ago by
Why not? I found a workaround for this problem, so it doesn't seem to be impossible to predict the behavior.
My workaround is:
document.getElementById("box").style.left = parseFloat(document.getElementById("box").style.left) + 1;
document.getElementById("box").style.top = parseFloat(document.getElementById("box").style.top) + 1;
Thanks for taking the time to contribute to the jQuery project! Using a browser's zoom on a page produces unexpected behavior and cannot be expected to produce the same numbers.