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
This commit is contained in:
parent
0e39c31c6e
commit
ba4664d279
1 changed files with 6 additions and 1 deletions
|
@ -115,11 +115,16 @@ export function useGestureEvents(ref: React.RefObject<HTMLDivElement>) {
|
||||||
|
|
||||||
if (delta.x === 0 && delta.y === 0) return
|
if (delta.x === 0 && delta.y === 0) return
|
||||||
|
|
||||||
|
const container = editor.getContainer().getBoundingClientRect()
|
||||||
|
|
||||||
const info: TLWheelEventInfo = {
|
const info: TLWheelEventInfo = {
|
||||||
type: 'wheel',
|
type: 'wheel',
|
||||||
name: 'wheel',
|
name: 'wheel',
|
||||||
delta,
|
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,
|
shiftKey: event.shiftKey,
|
||||||
altKey: event.altKey,
|
altKey: event.altKey,
|
||||||
ctrlKey: event.metaKey || event.ctrlKey,
|
ctrlKey: event.metaKey || event.ctrlKey,
|
||||||
|
|
Loading…
Reference in a new issue