Skip to main content

Bug Tracker

Side navigation

#8834 closed bug (invalid)

Opened April 10, 2011 09:48AM UTC

Closed April 10, 2011 01:53PM UTC

Last modified April 25, 2012 12:35AM UTC

Bug in offset changing in chrome during zoom

Reported by: domshlak@gmail.com 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>

Attachments (0)
Change History (3)

Changed April 10, 2011 01:53PM UTC by timmywil comment:1

resolution: → invalid
status: newclosed

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.

Changed April 10, 2011 02:10PM UTC by anonymous comment:2

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;

Changed April 25, 2012 12:35AM UTC by rwaldron comment:3

#11639 is a duplicate of this ticket.