Side navigation
#12594 closed bug (duplicate)
Opened September 22, 2012 11:55PM UTC
Closed September 23, 2012 12:07AM UTC
Last modified September 23, 2012 03:24PM UTC
width() returns float when zoomed
Reported by: | contact@countlessprojects.com | 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
Attachments (0)
Change History (6)
Changed September 23, 2012 12:03AM UTC by comment:1
Changed September 23, 2012 12:07AM UTC by comment:2
resolution: | → duplicate |
---|---|
status: | new → closed |
Duplicate of #11298.jQuery only supports use in 100% zoom
Changed September 23, 2012 12:49AM UTC by comment:3
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?"
Changed September 23, 2012 01:07AM UTC by comment:4
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.
Changed September 23, 2012 02:43AM UTC by comment:5
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.
Changed September 23, 2012 03:24PM UTC by comment:6
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/