Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 为raphael svg路径创建一个边界框_Jquery_Html_Svg_Raphael_Draggable - Fatal编程技术网

Jquery 为raphael svg路径创建一个边界框

Jquery 为raphael svg路径创建一个边界框,jquery,html,svg,raphael,draggable,Jquery,Html,Svg,Raphael,Draggable,我使用raphael.js2.1.2和raphael.sketchpad.js来绘制svg路径。 我希望使用getBBox在svg路径周围创建边界框,以便可以应用各种操作选择、拖动它 下面是我画一条小直线时生成的代码 <svg height="7866" version="1.1" width="857" xmlns="http://www.w3.org/2000/svg" id="svg_id" style="overflow: hidden; position: absolut

我使用raphael.js2.1.2和raphael.sketchpad.js来绘制svg路径。 我希望使用getBBox在svg路径周围创建边界框,以便可以应用各种操作选择、拖动它

下面是我画一条小直线时生成的代码

    <svg height="7866" version="1.1" width="857" xmlns="http://www.w3.org/2000/svg" id="svg_id" style="overflow: hidden; position: absolute; z-index: 3; pointer-events: visiblepainted; left: -0.09375px; top: 0px; -webkit-user-select: text;">

    <desc style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-user-select: text;"></desc>

    <defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-user-select: text;"></defs>

    <path fill="none" stroke="#000000" d="M160.90625,62L160.90625,63L162.90625,65L162.90625,70L163.90625,74L163.90625,
76L163.90625,78L163.90625,79" stroke-opacity="1" stroke-width="2" 
stroke-linecap="round" stroke-linejoin="round" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); stroke-opacity: 1; 
stroke-linecap: round; stroke-linejoin: round; -webkit-user-select: text;"></path>

    </svg>
我的问题是如何首先为每个svg路径元素创建边界框? 在哪里生产?如果我想使路径可拖动,使边界框对我有任何帮助吗


任何帮助都将不胜感激

我认为您可以使用canvas元素,它将在您放置它的任何位置生成,假设您使用Raphael use getBBox自己创建它,然后根据它的值创建s.rect。我认为您需要对js/raph代码做一个JSFIDLE,以使问题更清楚。我不知道边界框如何帮助您拖动元素,除非您希望通过边界框拖动。只需在路径上附加一个Raph拖动处理程序。谢谢Ian Li,我现在明白了边界框不能帮助我拖动。但是,我已经实现了选择svg路径元素。