From c3663202dade896078d3466fccdcbac11909f2ba Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 28 Oct 2009 12:04:53 +1000 Subject: 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. --- examples/declarative/dynamic/itemCreation.js | 10 +++++----- 1 file 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) -- cgit v0.12