开发者

SVG: alternatives to appendNode for 'bring to front'

开发者 https://www.devze.com 2023-03-11 18:23 出处:网络
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.

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消