offsetLeft = undefined for draggable image


(Jan) #1

When placing an image on the stage to create a drag and drop object (like the star in NoaStars) I noticed .offsetLeft is undefined. I need this to check if the object has been dropped on the drop area.

Ex.:
var vDragObj = document.getElementById(‘dragobj’);
objXCenter = vDragObj.offsetLeft + (vDragObj.offsetWidth / 2);
alert(vDragObj.offsetLeft);

When converting the image to a group, assigning the element-id to the group and removing the id from the image, using the same script everything works fine. So my question is why the offsetLeft (or offsetTop) is not available for an image. Is this a bug or a feature?

Best regards,
Jan


(Hans-Gerd Claßen) #2

should work, though hype recommend getBoundingClientRect() as of its own functional principles to get correct data. you should share a example …