Fix firefox dimension calculation

This commit is contained in:
Liu Xiaoyi 2024-03-31 20:10:43 +08:00
parent 5e7f81f61f
commit a4673145ee
No known key found for this signature in database
GPG Key ID: A04E02BF7E977471
2 changed files with 9 additions and 4 deletions

View File

@ -539,8 +539,10 @@ function reassemble() {
var vbox = sym.viewBox.baseVal;
// TODO: handle browsers without baseVal
// TODO: handle origins other than 0,0
var scale = width / vbox.width;
var vscale = height / vbox.height;
// Firefox fucks up its dimension calculation
var parentDims = trace.parentElement.getBoundingClientRect();
var scale = parentDims.width / vbox.width;
var vscale = parentDims.height / vbox.height;
// if(scale > vscale * 1.01 || scale < vscale * 0.99)
// console.warn(`incompatible scales: ${scale}, ${vscale}`);
var paths = symbolCache[sym.id];

View File

@ -553,8 +553,11 @@ function reassemble() {
// TODO: handle browsers without baseVal
// TODO: handle origins other than 0,0
const scale = width / vbox.width;
const vscale = height / vbox.height;
// Firefox fucks up its dimension calculation
const parentDims = trace.parentElement!.getBoundingClientRect();
const scale = parentDims.width / vbox.width;
const vscale = parentDims.height / vbox.height;
// if(scale > vscale * 1.01 || scale < vscale * 0.99)
// console.warn(`incompatible scales: ${scale}, ${vscale}`);
const paths: string[] | undefined = symbolCache[sym.id];