Friday, September 9, 2016

jsinterop with browser-specific api

Hi all. I'm trying to understand how can I effective work with jsinterop and browser-specific api.
For example Fullscreen api is mostly work in latest browsers, but methods are prefixed.

Before jsinterop I was write something like this:

public static native void leaveFullscreen() /*-{
if ($doc.cancelFullscreen) {
$doc.cancelFullscreen();
} else if ($doc.mozCancelFullScreen) {
$doc.mozCancelFullScreen();
} else if ($doc.webkitCancelFullScreen) {
$doc.webkitCancelFullScreen();
}
}-*/; 

What should I do now? Add 
mozCancelFullScreen, webkitCancelFullScreen methods to my jsinteropped Document interface? And then add static jsni method
boolean exists(Object a)
/*-{return a;}-*/; and add java method with "if (exists(..))"  chain. 
It looks very verbose and 
inefficiently.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment