summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-10-28 02:04:53 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-10-28 02:04:53 (GMT)
commitc3663202dade896078d3466fccdcbac11909f2ba (patch)
treeaa118c0437061a7338b5c88bcb6f54c12e751d77 /examples
parentc402509ea06a976a2a8ca671bec73f2fa3bd08f8 (diff)
downloadQt-c3663202dade896078d3466fccdcbac11909f2ba.zip
Qt-c3663202dade896078d3466fccdcbac11909f2ba.tar.gz
Qt-c3663202dade896078d3466fccdcbac11909f2ba.tar.bz2
Better dragging of items for dynamic example
The mouse is no longer at 0,0 of dragged item, but rather at the same point as the original click.
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/dynamic/itemCreation.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/declarative/dynamic/itemCreation.js b/examples/declarative/dynamic/itemCreation.js
index 3c3123b..06e67c5 100644
--- a/examples/declarative/dynamic/itemCreation.js
+++ b/examples/declarative/dynamic/itemCreation.js
@@ -20,7 +20,7 @@ function setSceneOffset()
function startDrag(mouse)
{
setSceneOffset();
- startingMouse = mouse;
+ startingMouse = { x: mouse.x, y: mouse.y }
loadComponent();
}
@@ -44,8 +44,8 @@ function createItem() {
draggedItem = itemComponent.createObject();
draggedItem.parent = window;
draggedItem.image = itemButton.image;
- draggedItem.x = startingMouse.x + xOffset;
- draggedItem.y = startingMouse.y + yOffset;
+ draggedItem.x = xOffset;
+ draggedItem.y = yOffset;
startingZ = draggedItem.z;
draggedItem.z = 4;//On top
} else if (itemComponent.isError) {
@@ -60,8 +60,8 @@ function moveDrag(mouse)
if(draggedItem == null)
return;
- draggedItem.x = mouse.x + xOffset;
- draggedItem.y = mouse.y + yOffset;
+ draggedItem.x = mouse.x + xOffset - startingMouse.x;
+ draggedItem.y = mouse.y + yOffset - startingMouse.y;
}
function endDrag(mouse)