Bug Tracker

Ticket #8834 (closed bug: invalid)

Opened 3 years ago

Last modified 2 years ago

Bug in offset changing in chrome during zoom

Reported by: domshlak@… Owned by:
Priority: undecided Milestone: 1.next
Component: unfiled Version: 1.5.2
Keywords: Cc:
Blocking: Blocked by:

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

comment:1 Changed 3 years ago by timmywil

  • Status changed from new to closed
  • Resolution set to invalid

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.

comment:2 Changed 3 years ago by anonymous

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;

comment:3 Changed 2 years ago by rwaldron

#11639 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.