-
Notifications
You must be signed in to change notification settings - Fork 161
Description
Hi,
In my code, I used context.translate() function in order to pan all drawings in the canvas. (e.g. dragging)
Since it is to move whole images in canvas, translate() function is being called while context is not in beginPath() mode.
It works perfectly with 2d canvas, but when I tried to export to SVG, intended panning is not applied.
It might be because canvas2svg code applying translate into individual path(?), not to rootGroup in this case. I am not sure.
I made some a temporary workaround solution. It works as I want but it is not much ideal. Here is what I did
var transX = this.boundingBox.translateX; // program tracks canvas level panning
var transY = this.boundingBox.translateY;
var t = "translate(" + transX + "," + transY + ")"; // build translate attribute
var rootGroup = ctx.__root.childNodes[1]; // it might not be ideal to touch __root element from out of canvas2svg ?
var transform = rootGroup.getAttribute("transform");
if (transform) {
transform += " ";
} else {
transform = "";
}
transform += t;
rootGroup.setAttribute("transform", transform);
Any thought?


