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.

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

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,

(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 …