<community>of XML and SVG Developers</community>
This is a discussion on Drag/dropping a group. within the SVG Questions forums, part of the SVG Forums category; I am trying to drag and drop a group, by clicking on and moving the top bar (a rect). I ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| <g id="group" > <rect x="150" y="85" width="50" height="30" style="fill: #00F" onmousedown="ClickObj(evt)" onclick="ClickObj(evt)" onmousemove="MoveObj(evt)" onmouseup="OutOfObj(evt)" onmouseout="OutOfObj(evt)"> </rect> <rect id="bar" x="150" y="85" width="50" height="10" style="fill: orange" onmousedown="ClickObj(evt)" onclick="ClickObj(evt)" onmousemove="MoveObj(evt)" onmouseup="OutOfObj(evt)" onmouseout="OutOfObj(evt)"> </rect> </g> Thanks for any help. |
| |||
|
You can - add transform attribute to your group <g transform="translate(0 0)"> ....... </g> - on click store values of translate ( using evt.target.parentNode.getAttribute("transform") by example or matrix - see example ) - on moving mouse, change attribute transform Example of code for ASV3 and ASV6 beta function ClickObj(evt) { clicked_group = true node = evt.target.parentNode if (ASV == 6) var matrix = node.getTransformToElement(node.parentNode) else var matrix = node.getCTM() xd1_group = parseFloat(matrix.e) - evt.clientX yd1_group = parseFloat(matrix.f) - evt.clientY } function MoveObj(evt) { if (!clicked_group) return dep_x = xd1_group + evt.clientX dep_y = yd1_group + evt.clientY node = evt.target.parentNode node.setAttribute("transform","translate(" + dep_x + " " + dep_y + ") ") } function OutOfObj(evt) { clicked_group = false } To test ASV version : var version = window.getSVGViewerVersion() if (version.indexOf("6.0") >= 0) ASV = 6 else ASV = 3 Michel |
![]() |
| Tags |
| drag or dropping, group |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Ink Cartridges...
Buy these ink cartridges, because only the highest quality of inks is used in the production process.
computer ink
Looking for good computer ink? We are specialists in printer ink. We provide a massive range of ink cartridges at great prices…
Hard Disk Drive Data Recovery North West
Desperate? Data Clinic offers a speedy and efficient data recovery service from your damaged hard disk drive, also in North West.