Mouseout breaks some click functionality
See original GitHub issueThis 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:
- Created 8 years ago
- Comments:5 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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:
CSS:
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:
lookupFillColor(geo.id)
on('mouseenter', (geo) => { lookupHighlightFillColor() }
on('mouseexit', (geo) => { lookupFillColor(geo.id)}
Currently
lookupFillColor
in step 3 isparse(data-previousAttributes).fillColor
, which leads to this bug.