यह वास्तव में खोजने के लिए मुश्किल था। SVGElement
के तरीकों के लिए खोज SVGElement
कहने वाले पृष्ठों में परिणाम नहीं हैं! यह वास्तव में करता है तरीकों में से एक टन है, लेकिन वे विरासत में मिला रहे:
http://www.w3.org/TR/SVG/types.html#InterfaceSVGLocatable
क्या आप आप एक
SVGPoint
को बदलने के लिए
getCTM
या
getScreenCTM
का परिणाम का उपयोग, और इस प्रकार जान सकते हैं कि आप कहां तत्व है चाहते हैं पर निर्भर करता है
:
root = document.getElementById('root')
rec = document.getElementById('rec')
point = root.createSVGPoint()
# This is the top-left relative to the SVG element
ctm = rec.getCTM()
console.log point.matrixTransform(ctm)
# This is the top-left relative to the document
ctm = rec.getScreenCTM()
console.log point.matrixTransform(ctm)
http://jsfiddle.net/kitsu_eb/ZXVAX/3/
स्रोत
2013-07-23 18:57:32
अच्छा! मैं matrixTransform के बारे में नहीं पता था। जावास्क्रिप्ट आपके बेवकूफ में खाली है। क्या आपने अपडेट किया इसका परीक्षण करने की कोशिश कर रहा है। –
काम करता है! धन्यवाद। वर्किंग फिडल: http://jsfiddle.net/T8aZP/14/ –
मैंने डीडेनो के जुड़ाव की कोशिश की, लेकिन मुझे नतीजे नहीं मिले। यहां एक कांटा है जो पॉइंट के प्रारंभिक तारों को सेट करने के लिए GetBBox का उपयोग करता है: http://jsfiddle.net/kitsu_eb/T8aZP/15/ –