Opera Mini 5b in Mobile View and getBoundingClientRect
Monday, September 21, 2009 4:11:30 AM
Opera Mini 4.2 and 5.0b have bad results with getBoundingClientRect.
Using Opera in "Mobile view", the device will scale a page's pixel values to smallish values, making the web page fit nicely on the small device screen.
Reading style values back using getComputedStyle returns the un-scaled values, so, if the element's top value was scaled from, say "20px" to "2px", then reading the value back, the value is re-scaled back to the script. Great, so all the scripts are portable, too.
I noticed that getBoundingClientRect returns values that seem to be
scaled to the device size, and not the de-scaled values.
http://dhtmlkitchen.com/ape/adhoctest/rect.html
Opera Mini "Mobile View" Result
style.top (20px): 20px coords.top: 3 getComputedStyle top: 20px
Opera Mini Result, not in "Mobile View"
style.top (20px): 20px coords.top: 20 getComputedStyle top: 20px
Opera Mini, in Mobile view is scaling pixel dimensions and de-scaling the read values. However the value getBoundingClientRect returns seems to be the scaled value.
When the page view is scaled in Firefox, using the browser's zoom in feature, getBoundingClientRect returns the de-scaled value (always 20). This is what I want it to do, so that the script does not have to perform calculations based on zoom level.
Opera Mini's implementation obviously makes finding position of an element complicated.
So I decided to see if the bug is fixed in Opera Mini 5 beta.
Testing the page using the default settings (not "Mobile view"), the example page shows coords.top: 20, however when switching to "Mobile view", I get the result coords.top: 3.
It would be easier to deal with an un-scaled value here. If getBoundingClientRect would return the un-scaled value. Hopefully Opera will recognize this as a bug and fix it.

