简体   繁体   English

检查svg元素是否在视图框内

[英]checking if svg element is inside the viewbox

having a SVG inline an HTML document , with a viewbox "xywh". 将SVG内联到HTML文档中,并使用视图框“xywh”。 How can I check if an element is inside the view box? 如何检查元素是否在视图框内?

by saying element it could be a nested child path inside a group and so on ... 通过说元素它可以是一个组内的嵌套子路径,依此类推......

so I think I'm looking for a build in function of SVG ,or a quick fast why to check it. 所以我认为我正在寻找SVG功能的构建,或快速快速检查它的原因。

I've tried saving the viewbox cords ,and the element I want to check if it's inside the viewbox I did something like : 我已经尝试保存视箱线,我要检查的元素是否在视图框内我做了类似的事情:

while (parent ! the svg element ...)
{
   parent = get elem parent 
} 

// now I have the most top parent of this element ,inside the svg doc now check if parent inside viewbox , if true then child also , otherwise false //现在我拥有了这个元素中最顶级的父元素,在svg doc中,现在检查viewbox中是否为parent,如果为true则为child,否则为false

也许你可以尝试SVGSVGElement的checkEnclosure方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM