javascript - Passing Elements (SVG) to web worker -
i have website need able take "snapshots" of animated svg @ different stages of animation (slow process). in parallel, animation running (fast process). i'm creating clone , in background i'm serializing svg @ different animation stages , uploading resulting images server.
however, being ran in background quite slow , tends slow down animation of original svg. possible in web worker? if necessary, worker can fetch svg source file itself.
i know passing dom element isn't possible:
//main.js var s = new xmlserializer(); worker.postmessage(s.serializetostring(svg)) //worker.js parser = new domparser(); doc = parser.parsefromstring(e.data, "text/html"); //error uncaught referenceerror: domparser not defined
and seems passing object isn't option either:
//main.js worker.postmessage(json.stringify(svg)) //worker.js svgobject = json.parse(e.data); console.log(svgobject) //console output (just empty object prototype) object {}
is web worker option worth pursuing, knowing need things like:
xmlserializer
(since domparser isn't available, don't know one)document.createelementns(svg_namespace, 'text')
(i need create elements within svg)var img = new image(); img.src = 'data:image/svg+xml;utf8,' + svgstring
(i need create image capture serialized version of svg)element.style.strokedashoffset = 0
(i need able style svg)svgpolylineelement.prototype.gettotallength
(i have couple polyfills on svg type prototypes math, turned functions)
Comments
Post a Comment