Modify ↓
Ticket #7885 (closed bug: fixed)
jQuery .offset doesn't property works when current offset is float (which is possible in FireFox)
| Reported by: | acc15 | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 1.6 |
| Component: | manipulation | Version: | 1.4.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Applies to
FireFox 3.6.13
How to reproduce
- jQuery 1.4.4
- FireFox 3.6.13
- Open test page
Test page:
<html>
<head>
<title>test</title>
<script type="text/javascript" src="jquery-1.4.4.js"></script>
</head>
<body>
<div id="test" style="position:ablosute;background-color:blue;left:10.7432222px;top:10.532325px;width:100px;height:100px;">TEST</div>
<script type="text/javascript">
$(document).ready(function() {
var expected = {left:100,top:100};
$('#test').offset(expected);
var actual = $('#test').offset();
alert(expected.left == actual.left && expected.top == actual.top ? 'bug has been fixed' : 'bug still remains, expected [' + expected.left + '; ' + expected.top +
'], actual [' + actual.left + '; ' + actual.top + ']');
});
</script>
</body>
</html>
Workaround
use
$('#test').css(expected);
Change History
comment:2 Changed 2 years ago by addyosmani
A slightly cleaner version in jsFiddle Live Test Case
comment:3 Changed 2 years ago by snover
- Status changed from new to closed
- Resolution set to patchwelcome
Related to 7730.
If Firefox decides to mangle the offset values there isn’t a lot that can be done. In any case, it’s not something that we are probably going to spend time on. Feel free to submit a patch that works consistently across all browsers without causing trouble with devices that support sub-pixel precision and we would be happy to consider it.
comment:4 Changed 2 years ago by jitter
- Component changed from unfiled to manipulation
- Milestone 1.6 deleted
comment:5 Changed 2 years ago by inukshuk
This is actually a great test case for #7730.
Possible patch here:
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

http://jsfiddle.net/tD4pC/1/
fiddle url...