the load handler *MUST* be set prior to the IMG's src attribute *and*
the IMG *MUST* be added to the DOM first. This is because IE loads
the image asynchronously as soon as the src attribute is set. So you
need to do this:
Image image = new Image();
image.addLoadHandler(new LoadHandler() { ... });
image.getElement().getStyle().setVisibility(Style.Visibility.HIDDEN);
RootPanel.get().add(image);
img.setUrl("android.png");
Also, IE (at least IE6 as I remember) doesn't calculate dimensions for
objects with display:none, which is why I changed the call
to .setVisible() to .getStyle().setVisibility(...);
On Nov 3, 3:21 pm, Thad <thad.humphr...@gmail.com> wrote:
> I've added this to Issue #6849http://code.google.com/p/google-web-toolkit/issues/detail?id=6848
>
> On Nov 3, 12:55 pm, Thad <thad.humphr...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Using GWT 2.3 and 2.4, IE9 does not set the dimensions of an image
> > after the image is loaded. In the code fragment below, IE9 will print
> > "dimensions: 0, 0":
>
> > Image image = new Image("android.png");
> > image.addLoadHandler(new LoadHandler() {
> > public void onLoad(LoadEvent event) {
> > GWT.log("dimensions: "+image.getWidth()+" x "+image.getWidth());
> > }
> > });
> > image.setVisible(false);
> > RootPanel.get().add(image);
>
> > This makes it impossible to scale or crop and image for display in an
> > SVG Canvas.
>
> > Firefox, Chrome, and Safari all give the correct dimensions.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment