Fix edge scrolling at odd browser zoom levels (#3973)

If you zoom in at 110% or more, edge scrolling was not working on the
bottom and right edges. That's because we were setting insets using
exact comparison when the document.body.scrollWidth/Height values were
slightly off integers.

### Change Type

<!--  Please select a 'Scope' label ️ -->

- [x] `sdk` — Changes the tldraw SDK
- [ ] `dotcom` — Changes the tldraw.com web app
- [ ] `docs` — Changes to the documentation, examples, or templates.
- [ ] `vs code` — Changes to the vscode plugin
- [ ] `internal` — Does not affect user-facing stuff

<!--  Please select a 'Type' label ️ -->

- [x] `bugfix` — Bug fix
- [ ] `feature` — New feature
- [ ] `improvement` — Improving existing features
- [ ] `chore` — Updating dependencies, other boring stuff
- [ ] `galaxy brain` — Architectural changes
- [ ] `tests` — Changes to any test code
- [ ] `tools` — Changes to infrastructure, CI, internal scripts,
debugging tools, etc.
- [ ] `dunno` — I don't know


### Test Plan

1. Add a step-by-step description of how to test your PR here.
2.

- [ ] Unit Tests
- [ ] End to end tests

### Release Notes

- Add a brief release note for your PR here.
This commit is contained in:
David Sheldrick 2024-06-18 15:58:52 +03:00 committed by GitHub
parent 57d0618ab7
commit e48f4bb798
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3044,9 +3044,9 @@ export class Editor extends EventEmitter<TLEventMap> {
// top
screenBounds.minY !== 0,
// right
document.body.scrollWidth !== screenBounds.maxX,
!approximately(document.body.scrollWidth, screenBounds.maxX, 1),
// bottom
document.body.scrollHeight !== screenBounds.maxY,
!approximately(document.body.scrollHeight, screenBounds.maxY, 1),
// left
screenBounds.minX !== 0,
]