Question

I use the GWT image class with a ClickHandler to trigger actions when specific areas of the image are clicked. In order to specify these areas, I use the image's dimensions. The problem occurs when you change the size of your browser window. While the image rescales nicely, the getWidth() and getHeight() methods still return the image's original size, not the size after rescaling.

Do you know a way to retrieve the current size of the image?

Was it helpful?

Solution

.getElement().getOffsetWidgth() ? and .getOffsetHeight().

I think thats what you need. That will return the current size of the element in the Dom, including any decorations like borders in the CSS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top