I would like my GWT widget to be notified when its CSS animation is over.
In plain HTML/Javascript this is easily done by registering an event handler like so:
Based on Darthenius' answer and Clay Lenhart's Blog, I finally settled for this solution:
private native void registerAnimationEndHandler(final Element pElement,
final CbAnimationEndHandlerIF pHandler)
/*-{
var callback = function(){
pHandler.@fully.qualified.CbAnimationEndHandlerIF::onAnimationEnd()();
}
if (navigator.userAgent.indexOf('MSIE') < 0) { // no MSIE support
pElement.addEventListener("webkitAnimationEnd", callback, false); // Webkit
pElement.addEventListener("animationend", callback, false); // Mozilla
}
}-*/;
The CbAnimationEndHandlerIF
is a simple custom EventHandler
interface:
public interface CbAnimationEndHandlerIF extends EventHandler
{
void onAnimationEnd();
}
Works like a charm! Thanks Darthenius!
If anyone can spot a weakness in this, of course I'd be happy to know.