Programming Tips - javaScript: get the current position of a dojox.gfx object?

Date: 2009aug6 Language: javaScript Libary: dojo Q. javaScript: get the current position of a dojox.gfx object? A. This function shows you how:
function getPosition(myshape) { const shape = myshape.getShape()
let trans = myshape.getTransform(); if (trans == null) { // will be null if it hasn't yet moved trans = { dx: 0, dy: 0 }; } const x = shape.x + trans.dx; const y = shape.y + trans.dy; return [x, y]; } function exampleUse() { let surface = dojox.gfx.createSurface(...); let rect = surface.createRect(...) new dojox.gfx.Moveable(rect); // ... later, after user has had a chance to move it ... let position = getPosition(rect); }