Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bringToFront() in IE on multipolygons loses event handler #4050

Closed
kingfisher13 opened this issue Nov 25, 2015 · 3 comments
Closed

bringToFront() in IE on multipolygons loses event handler #4050

kingfisher13 opened this issue Nov 25, 2015 · 3 comments
Assignees
Labels
bug ie Internet Explorer
Milestone

Comments

@kingfisher13
Copy link

Browser - IE 9-11 have problems, Chrome (latest stable - 46) and Firefox (latest stable - 42) are fine.
Leaflet version - 0.7.7

JSFiddle - https://jsfiddle.net/fd967s4n/2/

Description: Added a simplified US States geojson to a standard Leaflet map. Attached mouse handlers using onEachFeature. All the mouse handler does is adjust the style, however if bringToFront() is used, the mouseout event doesn't fire on multipolygons in IE.

See Michigan, Alaska, Hawaii, and Virginia in the above fiddle.

Tested this on 1.0.0-beta.2 and it's worse. IE doesn't register a mouseout for any polygon. Chrome and Firefox again do just fine. Again, removing the bringToFront() function call fixes the display bug in IE11, though obviously removes the needed functionality of bringing the poly to the front.

@rendrom
Copy link

rendrom commented Apr 18, 2017

I have the same problem:
https://jsfiddle.net/rendrom/xtcsLpnd/

@perliedman
Copy link
Member

Wow, we obviously dropped the ball on the original bug report here. Sorry.

I can reproduce this and it turns out the problem is that bringing the element to front fires another mouseover in IE. This causes an a loop of bringToFront calls in this case. and (I'm guessing) this also causes no mouseout to be fired, since it thinks the mouse isn't over the feature.

A workaround is implementing the mouseover listener like this:

var bringingToFront = false;
geojson.on("mouseover", function (e) {
    console.log("mouseover");
    if (!bringingToFront) {
    	bringingToFront = true;
    	e.target.bringToFront();
    } else {
    	bringingToFront = false;
    }
});

Hopefully we can come up with a more elegant fix that we can put into Leaflet.

perliedman pushed a commit that referenced this issue Apr 18, 2017
Addresses problem where Internet Explorer re-fires mouseover if
the element is re-appended to the DOM.

Fixes #4050.
@perliedman perliedman self-assigned this Apr 18, 2017
@perliedman
Copy link
Member

Found a better way to fix this, submitted as #5465.

IvanSanchez pushed a commit that referenced this issue Apr 18, 2017
Addresses problem where Internet Explorer re-fires mouseover if
the element is re-appended to the DOM.

Fixes #4050.
@Malvoz Malvoz added the ie Internet Explorer label May 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ie Internet Explorer
Projects
None yet
Development

No branches or pull requests

5 participants