Ticket #882 (closed bug: fixed)

Opened 6 years ago

Last modified 6 years ago

JS error after using mousewheel without having moved the mouse before

Reported by: openlayers Owned by:
Priority: major Milestone: 2.5 Release
Component: Handler.MouseWheel Version: 2.4
Keywords: Cc: nicolas.malaval@…
State:

Description

How to reproduce the bug :
Load any documents using OL with Firefox :
1) Put the cursor into the map
2) Refresh the document without moving the cursor
3) Move the mousewheel up or down. You'll get a JS error in Firebug(evt.xy has no properties) until you move the mouse

I may have identified the problem :

            if (delta) {
                // add the mouse position to the event because mozilla has a bug
                // with clientX and clientY (see https://bugzilla.mozilla.org/show_bug.cgi?id=352179)
                // getLonLatFromViewPortPx(e) returns wrong values
                e.xy = this.mousePosition;
                if (delta < 0) {
                   this.callback("down", [e, delta]);
                } else {
                   this.callback("up", [e, delta]);
                }
            }

this.mousePosition is only set after a mouse move. That is why evt.xy has no properties.

Attachments

handler.patch Download (6.5 KB) - added by crschmidt 6 years ago.

Change History

Changed 6 years ago by crschmidt

Changed 6 years ago by crschmidt

  • keywords review added

If we don't have an xy after trying to get it from mousePosition, we should just take the center lat/lon of the map. With tests for the specific bad behavior -- note that the tests will not actually fail in IE, because this is a workaround for a FF bug.

Changed 6 years ago by crschmidt

Tests all pass in IE and FF.

Changed 6 years ago by tschaub

  • keywords commit added; review removed

Confirmed that tests pass in IE/FF - and wheeling before wiggling now works in FF.

Nice work. Please commit.

Changed 6 years ago by crschmidt

  • keywords commit removed
  • status changed from new to closed
  • resolution set to fixed

(In [4042]) "JS error after using mousewheel without having moved the mouse before." Update MouseWheel handler to use center of map if no mousemovement has been seen yet. (Closes #882)

Note: See TracTickets for help on using tickets.