Re: Problems using native JavaScript library (Snap)

2014-03-09 Thread Magnus
These two examples work like hell! :-) It would be of great help if you could debug JS code somehow... Especially for future problems with SVG topics. Magnus -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To unsubscribe from this group

Re: Problems using native JavaScript library (Snap)

2014-03-07 Thread Jens
The following approaches work: public class SnapSvgWidget extends Widget { public SnapSvgWidget() { setElement(Document.get().createDivElement()); drawExample(getElement()); } private native void drawExample(Element container) /*-{ var paper = $wnd.Snap(400,400)

Re: Problems using native JavaScript library (Snap)

2014-03-06 Thread Magnus
Any idea how to solve this? An attempt was made to reference a Node in a context where it does not exist. I receive this message whenever I try to connect the svg element to a parent. Thanks Magnus -- You received this message because you are subscribed to the Google Groups "Google Web Too

Re: Problems using native JavaScript library (Snap)

2014-03-05 Thread Magnus
On Wednesday, March 5, 2014 7:56:45 PM UTC+1, Jens wrote: > > It seems that the existing svg element is not recognized by the Snap >> constructor. >> This was also noticed >> here

Re: Problems using native JavaScript library (Snap)

2014-03-05 Thread Jens
> > It seems that the existing svg element is not recognized by the Snap > constructor. > This was also noticed > here, > > but the solution (adding more attributes to the

Re: Problems using native JavaScript library (Snap)

2014-03-05 Thread Magnus
On Wednesday, March 5, 2014 10:19:51 AM UTC+1, Jens wrote: > > // set empty div as widget element: > Element e = Document.get().*createElement("svg"); // Snap() needs a > svg element, see docs.* > *Yes, one overloaded method expects a svg element. I also tested this, but...* var s =

Re: Problems using native JavaScript library (Snap)

2014-03-05 Thread Jens
Code below is untested: public class GraphicsWidget extends Widget { private static boolean injected = false; public GraphicsWidget() { if (!injected) { MyGraphics.injectSnap (); injected = true; } // set empty div as widget element: Element e = Document.get().*createElem

Re: Problems using native JavaScript library (Snap)

2014-03-04 Thread Magnus
Hi, I modified the injection code like this: class MyGraphics { ... public static void injectSnap () { LibraryBundle b = GWT.create (LibraryBundle.class); FromString f = ScriptInjector.fromString (b.srcSnap().getText()); f.setWindow (ScriptInjector.TOP_WINDOW); f.inject(); } }

Re: Problems using native JavaScript library (Snap)

2014-03-04 Thread Magnus
On Tuesday, March 4, 2014 5:55:35 PM UTC+1, Jens wrote: >When injecting your script, make sure you inject it into the top window >> (setWindow(ScriptInjector.TOP_WINDOW)), then reference your globals within >> $wnd. >> How exactly would you modify the injection code above? >> > > Ehh...b

Re: Problems using native JavaScript library (Snap)

2014-03-04 Thread Jens
> > When I use $wnd.Snap, I get: > > Object [object global] has no method 'Snap' > > > And the first library (SVGJS) works without $wnd. > > I inject like this: > LibraryBundle b = GWT.create (LibraryBundle.class); > ScriptInjector.fromString (b.svgLib().getText()).inject(); > If you use $wn

Re: Problems using native JavaScript library (Snap)

2014-03-04 Thread Magnus
Hi Thomas! I find it very strange that you do not use $wnd.SVG() or $wnd.Snap(), but > just SVG() or Snap(). > When I use $wnd.Snap, I get: Object [object global] has no method 'Snap' And the first library (SVGJS) works without $wnd. I inject like this: LibraryBundle b = GWT.create (Libra

Re: Problems using native JavaScript library (Snap)

2014-03-04 Thread Thomas Broyer
I find it very strange that you do not use $wnd.SVG() or $wnd.Snap(), but just SVG() or Snap(). When injecting your script, make sure you inject it into the top window (setWindow(ScriptInjector.TOP_WINDOW)), then reference your globals within $wnd. I suppose your errors come from using nodes cro