This project is archived and is in readonly mode.

#457 ✓invalid
TJ111

getCoordinates not accurate after window.fireEvent('resize')

Reported by TJ111 | November 4th, 2008 @ 06:44 PM | in 1.3.0 rc2 (closed)

If you manually fire a resize event on the window object, subsequent calls (in the stack) to Element.getCoordinates() will not be accurate.

On any website (using mootools 1.2.1 and firebug), do the following to reproduce:

In firebug, in "large" input mode, run the following code (replace 'report' with any element on the page, even document.body).

var test = function() {

console.log( $('report').getCoordinates() );

}

window.addEvent('resize', test); test();

window.fireEvent.delay(50, window, 'resize');

Expected result: Identical objects should be logged.

Actual result:

Object left=25 top=446 width=911 height=26 right=936

Object left=25 top=174 width=911 height=325 right=936

Comments and changes to this ticket

  • TJ111

    TJ111 November 4th, 2008 @ 06:47 PM

    Fixing some formatting errors (I hope).

    var test = function() { console.log( $('report').getCoordinates() ); } window.addEvent('resize', test); test(); window.fireEvent.delay(50, window, 'resize');

    Expected result: Identical objects should be logged.

    Actual result: Object left=25 top=446 width=911 height=26 right=936 Object left=25 top=174 width=911 height=325 right=936

  • fakedarren

    fakedarren February 8th, 2010 @ 05:17 PM

    • Milestone changed from 2.0 to 1.3.0 rc2
    • State changed from “new” to “open”
    • Assigned user changed from “Valerio” to “fakedarren”
  • fakedarren

    fakedarren February 11th, 2010 @ 07:14 PM

    TJ111, any chance you can create a mooshell for this? http://mootools.net/shell. It would be a great help; we'll look into this shortly.

  • fakedarren

    fakedarren February 15th, 2010 @ 10:19 PM

    • State changed from “open” to “invalid”

    I have to assume this is invalid. Here's my thinking:

    You call getCoordinates() / getDimensions() whatever prior to complete page load. Images etc have not yet loaded.

    Page size is x1 x y1 because images are not loaded.

    You delay, images load, page dimensions change.

    If you can confirm this is still an issue, I'll re-open, but until then, I have to mark as invalid unless a test case can be provided.

    Apologies for delay in responding to the original ticket. Won't happen again.

  • TJ111

    TJ111 February 18th, 2010 @ 03:06 PM

    Ssorry for taking so long to reply to this ticket. This is an old ticket, and as such I can't really remember the ins and outs of what caused it, but looking through my old code I can see that my workaround was to add a delay of 50ms to the call to get correct coordinates.

    This was called initially after the domready event, so it's possible it was due to images not being loaded, however the only images really being loaded were icons for the app I was producing, and all elements I was measuring were produced programmatically in JS before the initial measurements taking place, so I doubt that is the case here.

    However when creating a test case for this, I can no longer produce these results. It's possible it was either fixed in a Mootools point release, or it was a browser bug in Firefox 3.0 (where I do my testing) that has been fixed now in Firefox 3.6. You can see a test-case here http://jsbin.com/icovo3/edit (use the preview option, then resize your browser window; requires a browser with JSON.stringify (couldn't get console.log to work right on jsbin)). If you want more info, let me know.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Pages