Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Images with the same value for left are not left aligned

When I set a moved image's left to the same left value of a known image, the two images are not left-aligned. I thought they should be. Am I missing something? Rough Code The result: I feel like I am missing something.
I went and looked and apparently this wasn't well-documented in the Wiki (sorry about that), but top/left coordinates are based on the center of an object in Roll20. So that's why when you set the left value to the same thing they are center-aligned. If you want to align them based on their top-left corner, you would need to take into account the width of the object. For example: obj2.set("left", Math.floor(obj1.get("left") - obj1.get("width") / 2 + obj2.get("width") / 2)); Would align obj2 to the same place as obj1's left-hand side. (Untested, but that should be right, anyway)
Thanks for the quick reply. I thought the centering was an accident and not expect behavior. I can move forward now that I know. It's probably too late to change but 'center' and 'middle' or 'centerX' and 'centerY' seem more intuitive than left and top. Thanks again. Your reply got me unstuck. Also, thanks for updating the Wiki.