Answer the question
In order to leave comments, you need to log in
Why doesn't the ng-mouseenter directive fire on elements created by the ng-if directive?
Good afternoon.
Together with AngularJS, SVG is used.
A number of circles are drawn in the SVG.
<defs>
<g id="test">
<circle cx="0" cy="20" r="20"/>
</g>
</defs>
<g ng-repeat="node in nodes" ng-mouseenter="focusIn()" ng-mouseleave="focusOut()">
<g ng-if="visible">
<ellipse id="2" cx="20" cy="0" rx="20" ry="20" />
<g >
<use id="3" xlink:href="#test" x="0" y="0" />
<g/>
<g/>
<circle id="1" cx="0" cy="0" r="20"/>
</g>
Answer the question
In order to leave comments, you need to log in
And it seems this is a problem specifically with the use tag. jQuery are you using?
I may be wrong, but I see the situation like this: Your
shapes id=1, id=2, id=3 , in theory, should be "one whole", since they are united by a common parent, for which mouseenter/mouseleave are set , and in the case of id=1 and id=2 , we see similar behavior; logically, the figure id=3 should have the corresponding behavior, i.e. when hovering over it, mouseenter shouldn't fire (it already fired when you hovered the mouse over the id=1 shape ) just shouldn't fire mouseleave either .
Perhaps this is due to geometry, and will help in <use>
setting the necessary coordinates instead of x=0 y=0 , putx=0 y=20 , and <defs>
do not set coordinates for the shape.
Or maybe mouseleave works because the shape is taken from outside, and it will work in any case (although, logically, it should not).
jQuery didn't want to use it yet.
iCat correctly noticed that mouseenter has already worked.
The question is how to make it so that mouseleave does not work when hovering over a figure with id=3. (chueyu considered this one with the figure id=1)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question