These are chat archives for opal/opal

20th
Nov 2018
Elia Schito
@elia
Nov 20 2018 00:36
@bwl21 have you tried attaching the event via DOM after the SVG has been attached to the document? I'm very familiar with events inside SVGs though, so I'm not really sure if it requires some special stuff.
Anyway I don't think you can avoid using globals easliy otherwise, Opal.top.… is still a global as you pointed out, so it would be any Opal class.
Bernhard Weichel
@bwl21
Nov 20 2018 07:11
@elia attaching the events via DOM seems to be the common approach. So this is what I am currently doing. But I have several hundred events to attach. As it blocks the UI thread, it is a performance issue. Attaching all events takes about 300 msec. I also think that it creates lots of closures consuming memory. Performance is the main reason that I want to attach the events in the SVG string. So I created a constant for the string "Opal.top.uicontroller".
Bernhard Weichel
@bwl21
Nov 20 2018 10:21
@elia you made me think twice ... I now attach the events via DOM again, but only the ones user moves the mouse on ( in a mouseover event). So I can reuse all of my code, SVG is smaller and performance is ok. I do not have to attach multiple events (mousdown, mouseup, mousemove) in the SVG string. Thanks. I was on the wrong way (like driving from Berlin to Brusses via New York :-) And I can still use the svg.draggable.js (https://github.com/wout/svg.draggable.js) library without inventing it new.
Elia Schito
@elia
Nov 20 2018 10:27
@bwl21 great to hear that! 👍👍👍