Xterm.js: .xterm-char-measure-element Dom width & height calculation error

Created on 30 Oct 2020  路  6Comments  路  Source: xtermjs/xterm.js



Can we change the getBoundingClientRect method under /browser/services/CharSizeService.ts to offsetWidth or offsetHeight to get the width and height?? cuz sometimes the getBoundingClientRect and Timeout do not get the width and height correctly

help wanted typbug

All 6 comments

I haven't seen any issues with this, is it a browser bug you're hitting? We need some more information on how to repro.

Oh....Here is the case: https://codesandbox.io/s/nifty-hill-1i7wz?file=/src/App.js ,When the style is set to transform: scale, xter uses the "getBoundingClientRect" with the wrong length and width, offset is normal

I don't think this edge case is that important, but maybe it could be improved by using ResizeObserver if it's available?

I think the problem is that getBoundingClientRect() provides the dimensions with transformations applied, whereas offsetHeight and offsetWidth provides the original dimensions without the transformations. In that sense, I would agree that using offsetHeight and offsetWidth is preferable over getBoundingClientRect() for our use-case. Still, as @Tyriar already stated, this is a very minor edge case.

I (only speaking for myself) would be open towards a PR that changes the measure from getBoundingClientRect() to offsetHeight and offsetWidth.

馃憤 if they're functionally equivalent outside of that

My current solution is to give up transform animation, if it can be changed, it鈥檚 really great!馃檪馃檭

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LB-J picture LB-J  路  3Comments

zhangjie2012 picture zhangjie2012  路  3Comments

circuitry2 picture circuitry2  路  4Comments

albinekb picture albinekb  路  4Comments

chris-tse picture chris-tse  路  4Comments