javascript - lagging mouse bahavior on SVG -
this question has answer here:
- css hover doesn't work on svg paths 2 answers
i'm working on tooth selection menu web-app i'm building. found svg , i'm modifying it.
i tried simplify mouse behavior, making large areas hoverable ('.parent') , other stuff {pointer-events:none}. however, there's major lag. when move mouse 1 of teeth, doesn't respond. when moving it.
do see also? can do?
$('.parent').mouseover(function(){ $(this).css('fill', 'red'); }); $('.parent').mouseleave(function(){ $(this).css('fill', 'none'); });
a simple change in css fixed issue:
svg *{ pointer-events: none; // disable pointer-events elements inside svg } svg .parent{ pointer-events: all; // enable pointer-events on elements } here's updated version of codepen: https://codepen.io/etiennemartin/pen/yovzzb
i changed way trigger mouseover, that's personal preference. looks cleaner me.
Comments
Post a Comment