XML Elves

XML Elves

<community>of XML and SVG Developers</community>


Drag/dropping a group.

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 ...


Go Back   XML Elves > SVG Forums > SVG Questions

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Notices


Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-09-2005, 03:34 PM
robzombie
Guest
 
Posts: n/a
Default Drag/dropping a group.

I am trying to drag and drop a group, by clicking on and moving the top bar (a rect). I am changing the x and y attributes of the rectangle, however since a group doesnt have an x and y attribute how could i get it so all the objects in the group move with the top bar? A simple example of how the group would look. By moving the top rect, i need all the objects in the group to move.

<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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-10-2005, 02:00 AM
Anonymous
Guest
 
Posts: n/a
Default Drag/dropping a group.

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-10-2005, 02:34 AM
Junior Member
 
Join Date: Jan 2005
Posts: 10
Default Drag/dropping a group.

the <use>-tag would also be an alternative...
Code:
<defs>
   <g id="group">
      ...
   </g> 
</defs>
<use id="object_to_be_moved" xlink:href="#group" x="0" y="0" />
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
drag or dropping, group


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -6. The time now is 10:03 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0

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.

ink cartridges Free UK Delivery on ink cartridges such as Canon, Dell, Epson, hp & Lexmark.

1 2 3 4 5 6 7 8 9 10