<community>of XML and SVG Developers</community>
This is a discussion on Grouping SVG element and groups using JavaScript within the SVG Questions forums, part of the SVG Forums category; Hello guys! Could you pls answer the question concerning the groups+JavaScript? I have some objects on canvas (for example circle, ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Could you pls answer the question concerning the groups+JavaScript? I have some objects on canvas (for example circle, rect, path,line). And I want to group them all or some of them (maybe only circle and line) by simple clicking on the corresponding subjects. But I have lack of JavaScript code concerning how better to produse this. Is there anybody know how to produse this properly? I need just to create <g>...</g> tags and insert selected elements between them. Using JavaScript of cource
__________________ rbeit gibt die Freilesung! |
| |||
|
Hi You have to 1- create group with group = document.createElementNS(null,"g") give id to this group group.setAttributeNS(null,"id","MyGroup") append group to main svg document.rootElement.appendChild(group) 2- clone node to put in group with new_node=evt.target.cloneNode(true) 3- append new node to group document.getElementById("MyGroup").appendChild(new _node) 4- delete moved node with evt.target.parentNode.removeChild(evt.target) You can adapt script with where put group in DOM tree. Michel |
| |||
Thank you guest! That was nice for you to help me. Now SVG seems much easier for me. Could you pls answer: How to extract DATA from nodes(elements, group)? I mean very necessary DATA, which contain x,y - coordinates, styles,id and other properties... Is it possible way to save this parameters into DATABASE? I do the following. Data->JavaScript variables->PHP variables->MySQL DATABASE. May be somebody know more easier way to store DATA? Best regards... _________________ Arbeit gibt die Freilesung!
__________________ rbeit gibt die Freilesung! |
| |||
|
Could you pls answer me the question: There some objects on canvas. How to write function on JavaScript which will connect these objects into group? :roll:
__________________ rbeit gibt die Freilesung! |
| |||
|
To get DATA from objects you can use Your_Node.attributes give list of attributes, with length you get number of attributes and with item(i) you get attribute and then name and value .... with Code: <rect x="10" y="20" width="200" ...... /> but some viewer parsing string change order of attributes .... To retrieve specific attribute you can use Your_Node.getAttributeNS(null,"x") to get value of x coordinate .... For text content is firstChild.data for text node Michel, |
| |||
|
I forget end of your question You can save in database or text file data with postURL or send to php file as variables For connecting objects in group, what will you make? Connect objects on graphic with lines? Group is only structure in DOM tree, you can give common attribute in group for objects (visible by example or color for filling ...) but group give not particular drawing Michel |
| |||
| Quote:
Code: PHP-variables($width, $height,$style) I wan to group elements into one LOGICAL group, which I can easyly drag on Canvas by simple mouse event. But while draging this group, it will be seem that all element included into group are draging in the same direction! I only want to add some interactivity on my pictures...
__________________ rbeit gibt die Freilesung! |
| |||
| Quote:
(Don't forget to send mime-type ... ) If you need html, you can use svg embedded in html. Michel |
Compatible Ink Cartridges
For remanufactured and compatible ink cartridges, click here.
canon cartridge
Buy your Canon cartridge online at Internet Ink. We offer discounted prices on a wide variety of canon cartridges.
Hard disk drive data recovery yorkshire
Need hard disk drive data recovery in Yorkshire? We collect all over the UK and never exceed our quotation.