我試圖在<g>
被翻譯後添加新的<circle>
。 的circle
座標我試圖用鼠標事件mousedown
函數來獲取 協調之前,我翻譯,我可以正確地在鼠標按下座標添加<circle>
但經過翻譯<g>
我不能正確地添加<circle>
在鼠標按下座標。
所以我想<g>
被翻譯後,我需要重新定義新的coordinate.But我只是不知道該怎麼做!
這裏是我的代碼(我用鼠標右鍵添加圓圈):
JSbind3.js-After翻譯<g>如何添加<circle>
0
A
回答
1
您將需要找到相對於組的翻譯的鼠標位置。
var point = document.getElementById('root').createSVGPoint();
point.x = event.pageX;//mouse position X
point.y = event.pageY;//mouse position Y
var newPoint = point.matrixTransform(container.node().getCTM().inverse());
//newPoint is the place where you will need to draw the circle
container.append('g')
.append('circle')
.attr('cx', newPoint.x)
.attr('cy', newPoint.y)
.attr('r', '20');
工作代碼here
希望這有助於!
0
嘗試族元素的getBBox方法。它將返回具有x,y位置的對象。他們會告訴你有多少元素被移動和朝哪個方向移動。
+0
thx,我也會嘗試。 –
相關問題
- 1. 如何使用翻譯服務,我使用angularJS翻譯指令翻譯<code>self employed</code>德國這樣</p> <pre><code>span(translate="translation_id") </code></pre> <p>翻譯過濾
- 2. 如何添加此翻譯?
- 3. 翻譯<>''到sql_oracle
- 4. symfony:如何翻譯含有文本<p></p>?
- 5. 添加<id> + <data>到D3-餅圖
- 6. D3翻譯價值
- 7. 添加翻譯模型翻譯
- 8. 如何添加觸發翻譯的Google翻譯鏈接?
- 9. rails多態添加<<
- 10. 如何將d3「翻譯」成功能?
- 11. Mozilla的翻譯<br></br>爲<br></br><br></br>
- 12. 如何添加翻譯器到CKEditor
- 13. 如何在Fullcalendar 1.6.2中添加翻譯?
- 14. 如何添加文檔的翻譯
- 15. 如何添加翻譯到Active模式
- 16. DataContext的翻譯<>匿名類型
- 17. Angular 2 i18n:翻譯<option>值
- 18. 角TranslateService翻譯<title>標籤
- 19. 翻譯到<升壓/ thread.hpp>
- 20. 翻譯可查詢<T>回IMongoQuery
- 21. Rails翻譯性能影響<%= raw t(vs. <%= t(
- 22. 翻譯JavaScript(d3)到Java
- 23. d3從v3翻譯到v4
- 24. <xsl:apply templates>如何應用多個模板/翻譯
- 25. 龜svn將<<<<添加到文件!
- 26. 如何我添加代碼到<script></script>
- 27. PrimeFaces - 如何在<p:toolbargroup>中添加<p:submenu>?
- 28. 如何在選定的<tr>下添加<tr>?
- 29. 如何在箭頭下方添加<<flow>>?
- 30. 如何添加<br>標籤鏈接<img>標籤?
感謝它爲我工作! –