4

As far as I can make out, the only way to bring something to the front is to delete/append, or just append. However, this is so inefficient that I thought I'd just check here first. I've got a complex set of objects which pop up on a mouseover (paths and text). I initially thought I'd handle this by creating one static instance of the popup, and hiding it. Whenever it's needed, I simply translate it and make it visible.

I thought this worked, but it turns out that it's transparent - anything which is created dynamically in a script appears on top of it. Is there any way to make this work? The alternative is to create it from scratch on every mouseover, and then to delete it on mouseout, which just feels wrong.

Thanks -

Al

EML
  • 9,619
  • 6
  • 46
  • 78
  • 1
    possible duplicate of [With javascript, can I change the Z index/layer of an svg "g" element?](http://stackoverflow.com/questions/482115/with-javascript-can-i-change-the-z-index-layer-of-an-svg-g-element) – Cristian Sanchez Jun 08 '11 at 17:39
  • added an alternative in http://stackoverflow.com/questions/482115/with-javascript-can-i-change-the-z-index-layer-of-an-svg-g-element (and yes, I think this is a duplicate - perhaps those questions could be merged) – Erik Dahlström Jun 09 '11 at 08:05

1 Answers1

0

You could give it an enormous z-index and toggle the visibility if it is positioned absolutely (or fixed) or the display if it is static. Least amount of redrawing is to position it absolutely or fixed, and toggle visibility between hidden and visible.

kennebec
  • 102,654
  • 32
  • 106
  • 127
  • 3
    The SVG specification doesn't define how that should work (read: it currently doesn't require z-index support). However, for the svg root element if it's subject to the CSS box model (such as for inline svg in html) then you can use z-index on the svg root only (since the CSS spec(s) then define how that works). There's however a proposal to add z-index inside of svg in the future, see http://www.w3.org/Graphics/SVG/WG/wiki/Proposals/z-index – Erik Dahlström Jun 09 '11 at 07:59