label.style.top=e.pageY + 'px';
label.style.left=e.pageX + 'px';
EvanED wrote:The SVG component is "non-negotiable" as the non-popup part is produced from a Dot file. (If Dot has another useful output option I'd listen to that as well.)
Xanthir wrote:First, mouseout happens *all the fucking time*. You'll get a mouseout event if you go from your element to a *child*, which is really annoying. mouseout is basically useless. (Same with mousein - it fires if you go from a child to the element.) IE got it right with their mouseenter/mouseleave events, which take the tree into account. Those are being specced and copied now.
To do mouseout right, always check event.relatedTarget. (It's useful for a bunch more events, too.) This still isn't trivial, as if the mouse moves fast enough it can "skip" elements, and so you have to handle some unexpected transitions as well. You could have used this, with some logic, to make your original popup situation work, by tracking when you mouseout into the popup and leaving it up then.
When possible, I try to just use CSS and the :hover pseudo, putting things that I want to "pop up" as children of a useful container. That way the browser handles all the bullshit for me. If you can do that, go for it - it's less fragile and a lot simpler.
Tangent: rather than using <object> to include an SVG in an HTML file, try one of these:
- use <iframe> - that's basically what <object> does in this situation, except the behavior is generally a touch saner.
- just include the <svg> directly in the HTML - all the modern browsers support this.
- just use a plain SVG file, running the <script> inside of it. Being "real" XML, you've gotta use a little more incantation to include a <script> (the @type is required, as is the CDATA thing, I believe.), but otherwise there's not a lot of difference between running JS in an SVG file versus an HTML file.
If you want a good, cross-browser way to determine an event's mouse coords, see PPK's event properties overview. Only screenX/Y are fully interoperable, but depending on what you're doing with those coords, you may have to massage the information slightly to get what you need out of it. The page shows you the compat story for all 6 of the coord pairs, though, so if you have lesser compat requirements you may be able to use something else.
Robert'); DROP TABLE *; wrote:EvanED wrote:The SVG component is "non-negotiable" as the non-popup part is produced from a Dot file. (If Dot has another useful output option I'd listen to that as well.)
EvanED wrote:I'm drawing pictures of finite automata using Graphviz Dot, using SVG output. I'd like to modify the output in an automatable way to add mouse hover events to the nodes to display some extra information. This extra information is a normal PNG file right now. (It's *conceivable* that I could output SVG here but that'd take some learning about the format then engineering.)
Users browsing this forum: No registered users and 14 guests