Dave's Brain

Browse - Programming Tips - How do I get the current position of a dojox.gfx object?

Date: 2009aug6
Language: javaScript
Libary: dojo

Q.  How do I get the current position of a dojox.gfx object?

A.  This function shows you how:

function getPosition(myshape) { var shape, trans, x, y; shape = myshape.getShape() trans = myshape.getTransform(); if (trans == null) { // will be null if it hasn't yet moved trans = { dx: 0, dy: 0 }; } x = shape.x + trans.dx; y = shape.y + trans.dy; return {x, y}; } function exampleUse() { var surface, rect, position; surface = dojox.gfx.createSurface(...); rect = surface.createRect(...) new dojox.gfx.Moveable(rect); // ... later, after user has had a chance to move it ... position = getPosition(rect); }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.