question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mouseout breaks some click functionality

See original GitHub issue

This is related to #191 (and another issue in angular-datamaps). When attempting to update the fill for a particular geography by clicking a geography and using updateChoropleth, the new color only persists until mouseout, when it reverts back to the value from data-previousAttributes. I’ve created a gist to demonstrate (http://bl.ocks.org/dmachat/b75a5a01cfb31cf92cf5/af5ce473d5ab0e96627775b374e8546f434c8cd6). Would be happy to take a swing at a fix eventually, but wanted to document and get any possible thoughts on the bug at this point.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
lucaspillercommented, Feb 10, 2016

I also had this issue and solved it with CSS, and it works fine for me. I don’t understand why JavaScript is used for highlighting / colouring.

Set this flag when initializing the map:

geographyConfig: {
  highlightOnHover: false
}

CSS:

#map path:hover { /* on mouse over */
  fill: #375682 !important;
}

#map path.active { /* on click */
  fill: #375682 !important;
}
1reaction
markmarkohcommented, Sep 27, 2015

Yes, this is definitely a bug. They say “never store state in the DOM”, but for this piece of functionality I did exactly that and bam, a bug appears.

Using data-previousAttributes might have to go away. Perhaps we could use a quick lookup to see what base color a geography is supposed to be (preferably the same lookup call that originally sets the color).

So the flow for painting would be:

  1. lookupFillColor(geo.id)
  2. on('mouseenter', (geo) => { lookupHighlightFillColor() }
  3. on('mouseexit', (geo) => { lookupFillColor(geo.id)}

Currently lookupFillColor in step 3 is parse(data-previousAttributes).fillColor, which leads to this bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Moving the mouse: mouseover/out, mouseenter/leave
The mouseover event occurs when a mouse pointer comes over an element, and mouseout – when it leaves. These events are special, because...
Read more >
Mouseout event fires before mouse is actually out
Since it works normally without timeouts I assume mouseover/mouseout is the correct event for you instead of mouseenter/mouseleave.
Read more >
onmouseout Event - W3Schools
The onmouseout event occurs when the mouse pointer moves out of an element. The onmouseout event is ... oncontextmenu, The user right-clicks on...
Read more >
Element: mouseout event - Web APIs | MDN
The mouseout event is fired at an Element when a pointing device (usually a mouse) is used to move the cursor so that...
Read more >
[Chrome] Click event isn't fired on L.marker when mouseover ...
It looks like when I have a L.marker created on a map which has an event 'mouseover' defined which changes L.marker icon it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found