Hi,
Actually I like to use JsniBundle to embed external javascript libraries. Unfortunately it doesn't work for this
one.
The generator create the file SVGMorpheusWrapper_SVGMorpheusJsniResource_Impl, with the following content :
public native void svgMorpheus()/*-{
(function(window, document, console){
function SVGMorpheus(element, options, callback) {
if (!element) {
throw new Error('SVGMorpheus > "element" is required');
}
if(typeof element === typeof '') {
element=document.querySelector(element);
if (!element) {
throw new Error('SVGMorpheus > "element" query is not related to an existing DOM node');
}
}
...
return SVGMorpheus;
}.apply($wnd, [$wnd, $doc, $wnd.console]));
}-*/;
When I use $wnd.SVGMorpheus, I have this error : Uncaught TypeError: undefined is not a function
There is no problem when the file is loaded with <script> tag.
I use an other
library that works perfectly. The generated file looks like :
public native void nprogress()/*-{
(function(window, document, console){
;(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.NProgress = factory();
}
})(this, function() {
var NProgress = {};
...
return NProgress;
});
}.apply($wnd, [$wnd, $doc, $wnd.console]));
}-*/;
and I can use $wnd.NProgess as well.
The construction of the functions is different and it seems that the 2nd way is better. Any solution to use the 1st one ?
Thanks !