在嵌入式SVG中拖放事件?

Rom*_*om1 10 svg drag-and-drop google-closure clojurescript

是否有可能从网页中的SVG元素接收拖放事件?

我尝试了Google Closure库,但无济于事.

具体来说,假设我的页面包含

<ul id = "list">
  <li class="item" id="item1">foo</li>
  <li class="item">bar</li>
  <li class="item">baz</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

我的脚本包含(Clojurescript/C2)

(let [items (select-all ".item")
      lst (select "#list")
      target (fx/DragDrop. lst nil)]
  (dorun (map
    (fn [item]
      (let [source (fx/DragDrop. item nil)]
        (. source (addTarget target))
        (. source (init))))
    items))
  (. target (init)))
Run Code Online (Sandbox Code Playgroud)

然后,我得到拖动图像(鬼),虽然我不设法接收例如通过做拖动事件

(on-raw "#item1" :dragstart (fn [e] (.log js/console (str "dragstart " e))))
Run Code Online (Sandbox Code Playgroud)

使用类似的SVG元素代码,我甚至没有鬼......

任何提示?

谢谢

met*_*ion 16

SVG Elements不支持拖动事件:http://www.w3.org/TR/SVG/svgdom.html#RelationshipWithDOM2Events.

您可以使用鼠标事件伪造拖动事件,请参阅http://svg-whiz.com/svg/DragAndDrop.svg(查看源代码).