问题
Following code results in the infinite animation on the latest (24.0.1312.52) version of Chrome. Same code runs well with FF/IE.
public class Test implements EntryPoint {
@Override
public void onModuleLoad() {
DeckLayoutPanel deck = new DeckLayoutPanel();
deck.setWidth("100%");
deck.setHeight("100px");
deck.setAnimationDuration(3000);
deck.setWidget(new Label("Hello world"));
RootLayoutPanel.get().add(deck);
}
}
Has anyone else encountered this problem as well?
回答1:
This is a bug in GWT 2.4 due to a change in Chrome where requestAnimationFrame now uses sub-milliseconds timers. This has been fixed in GWT 2.5.0.
See https://groups.google.com/d/topic/google-web-toolkit/UBWsvHYM4SE and https://plus.google.com/113357348071579443502/posts/apHjmAcynRa, among others.
回答2:
Thomas is precisely correct and this is a bug in GWT 2.4 that was correct in GWT 2.5.
If you are still using GWT 2.4, many issues that have come up with the newest chrome build can be remedied by the following conversation.
https://groups.google.com/forum/#!topic/google-web-toolkit/UBWsvHYM4SE
FTA: Summary for workaround is to add the following to your .gwt.xml file:
<!-- TEMP FIX UNTIL GOING TO GWT 2.5 -->
<!-- Fallback implementation, based on a timer -->
<replace-with class="com.google.gwt.animation.client.AnimationSchedulerImplTimer">
<when-type-is class="com.google.gwt.animation.client.AnimationScheduler"/>
<any>
<when-property-is name="user.agent" value="ie6"/>
<when-property-is name="user.agent" value="ie8"/>
<when-property-is name="user.agent" value="ie9"/>
<when-property-is name="user.agent" value="safari"/>
<when-property-is name="user.agent" value="opera"/>
</any>
</replace-with>
<!-- Implementation based on mozRequestAnimationFrame -->
<replace-with class="com.google.gwt.animation.client.AnimationSchedulerImplMozilla">
<when-type-is class="com.google.gwt.animation.client.AnimationScheduler"/>
<when-property-is name="user.agent" value="gecko1_8"/>
</replace-with>
<!-- ************* END ************* -->
来源:https://stackoverflow.com/questions/14317709/gwt-decklayoutpanel-animation-goes-into-infinite-loop-on-chrome