#12594 closed bug (duplicate)
width() returns float when zoomed
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.8.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
http://api.jquery.com/width/ says that width() is supposed to return integers only, but in Chrome and Firefox it is returning floating-point values if the page is zoomed. IE does not exhibit this problem for me.
Sample:
<!doctype html> <html> <script src='jquery-1.8.2.min.js'></script> <script> $(document).ready(function() { setInterval(function() { $('#div').text($('#div').width()); }, 30); }); </script> <body> <div id='div' style='width:300px; height:300px; border: solid'></div> </body> </html>
In chrome & firefox, if I zoom in/out (ctrl+ and ctrl-), I expect the number displayed to stay 300, but instead it changes to 299.3333330154419, 299.9909906387329, 300.5454545021057, etc.
- jquery 1.8.2
- win7 64bit
- chrome 22.0.1229.64 beta-m
- firefox 14.0.1
Change History (6)
comment:1 Changed 11 years ago by
comment:2 Changed 11 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Duplicate of #11298.
jQuery only supports use in 100% zoom
comment:3 Changed 11 years ago by
Is there a canonical place where the "only supports 100% zoom" policy is documented? It is a surprise to me and I've been using jquery for years. I'm also unable to find it mentioned outside of passing references in bugs.
Are there any suggested workarounds other than just popping up a warning like "sorry your zoom level is not supported?"
comment:4 Changed 11 years ago by
That's exactly the problem, there is no way to know if the viewport is zoomed. It doesn't need to be "canonically documented" as it's not a jQuery issue.
comment:5 Changed 11 years ago by
I had no way to know jQuery wouldn't work with zoom, though. It isn't written down anywhere outside of bugs. I would have been less confused (and wouldn't have bothered to open this bug) if the API docs mentioned that zoom led to undocumented behavior. That said, I would understand if this is deemed too esoteric an issue to warrant mentioning in the docs, though.
I also would have been helped by knowing that other methods of getting the width (such as .css(width) and .clientWidth) work correctly when zooming in chrome & FF.
comment:6 Changed 11 years ago by
I opened this ticket against the docs to see if they'll add a note about zoom not working well: https://github.com/jquery/api.jquery.com/issues/76
Sorry, I didn't see the note about using jsFiddle until after I posted. Here's the same sample:
http://jsfiddle.net/JfrHK/