fix scroll event coords (#2180)

Follow up to #2149 to make sure it works when tldraw is not mounted at
0,0 in document space. Try it out in the 'multiple' examples

### Change Type

- [x] `patch` — Bug fix
pull/2182/head
David Sheldrick 2023-11-08 14:34:26 +00:00 zatwierdzone przez GitHub
rodzic 0e39c31c6e
commit ba4664d279
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 6 dodań i 1 usunięć

Wyświetl plik

@ -115,11 +115,16 @@ export function useGestureEvents(ref: React.RefObject<HTMLDivElement>) {
if (delta.x === 0 && delta.y === 0) return
const container = editor.getContainer().getBoundingClientRect()
const info: TLWheelEventInfo = {
type: 'wheel',
name: 'wheel',
delta,
point: new Vec2d(event.x, event.y),
point: new Vec2d(event.clientX, event.clientY).sub({
x: container.left,
y: container.top,
}),
shiftKey: event.shiftKey,
altKey: event.altKey,
ctrlKey: event.metaKey || event.ctrlKey,