Skip to content

Commit 928dae9

Browse files
authored
Compare floats with margin of error to avoid infinite recurrence (#530)
With some specific zoom (e.g. 110%), browser can report slightly different values of divs that cover the same area, leading to infinite recurrence Signed-off-by: Eryk Szpotanski <[email protected]>
1 parent 9d50a6e commit 928dae9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/gl/graphics.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,9 @@ export namespace WebGL {
478478
if (
479479
this._width === widthInPixels &&
480480
this._height === heightInPixels &&
481-
bounds.width === widthInAppUnits &&
482-
bounds.height === heightInAppUnits
481+
// Compare floats with margin error
482+
Math.abs(bounds.width - widthInAppUnits) < 0.02 &&
483+
Math.abs(bounds.height - heightInAppUnits) < 0.02
483484
) {
484485
// Nothing to do here!
485486
return

0 commit comments

Comments
 (0)