仅在可用区域中拖放svg路径

时间:2018-06-03 19:48:07

标签: svg drag-and-drop

我需要拖放svg元素(路径),但只能在可用区域(rect)内部。我怎么能这样做?

<svg xmlns="http://www.w3.org/2000/svg" 
   xmlns:xlink="http://www.w3.org/1999/xlink" app-context="doc-2d" x="0px" 
   y="0px" width="600px" height="900px">

   <rect transform="matrix(1,0,0,1,115.04612731933594,153.07086181640625)" width="357.52980041503906" height="482.1732177734375" fill="rgba(255,255,255,1)" stroke="#000000" stroke-width="2.11" stroke-linecap="butt" stroke-linejoin="miter" opacity="1"></rect>

   <path id="drag-element" fill="url(#__1521276821859__)" stroke="rgba(201,122,122,1)" stroke-width="14" stroke-linecap="butt" stroke-linejoin="miter" opacity="1" d="M 190.48818969726562 337.8492736816406 L 228.7559051513672 236.16647338867188 L 330.4386901855469 270.06072998046875 L 390.57366943359375 368.46343994140625 L 254.9966278076172 446.09222412109375 L 190.48818969726562 337.8492736816406 Z" transform="translate(-15, 1)"></path>
</svg>

Example of svg

0 个答案:

没有答案