fix input coords while viewport following (#4108)

closes [#4106](https://github.com/tldraw/tldraw/issues/4106)

### Change type

- [x] `bugfix`
- [ ] `improvement`
- [ ] `feature`
- [ ] `api`
- [ ] `other`

### Test plan

1. Create a shape...
2.

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

### Release notes

- Fixed a bug with…
This commit is contained in:
David Sheldrick 2024-07-09 11:33:42 +01:00 committed by GitHub
parent 710a70bf0e
commit 7e561e54e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2071,7 +2071,7 @@ export class Editor extends EventEmitter<TLEventMap> {
/** @internal */ /** @internal */
@computed @computed
private getCameraId() { private _unsafe_getCameraId() {
return CameraRecordType.createId(this.getCurrentPageId()) return CameraRecordType.createId(this.getCurrentPageId())
} }
@ -2081,7 +2081,7 @@ export class Editor extends EventEmitter<TLEventMap> {
* @public * @public
*/ */
@computed getCamera(): TLCamera { @computed getCamera(): TLCamera {
const baseCamera = this.store.get(this.getCameraId())! const baseCamera = this.store.get(this._unsafe_getCameraId())!
if (this._isLockedOnFollowingUser.get()) { if (this._isLockedOnFollowingUser.get()) {
const followingCamera = this.getCameraForFollowing() const followingCamera = this.getCameraForFollowing()
if (followingCamera) { if (followingCamera) {
@ -8333,7 +8333,7 @@ export class Editor extends EventEmitter<TLEventMap> {
} = this.inputs } = this.inputs
const { screenBounds } = this.store.unsafeGetWithoutCapture(TLINSTANCE_ID)! const { screenBounds } = this.store.unsafeGetWithoutCapture(TLINSTANCE_ID)!
const { x: cx, y: cy, z: cz } = this.store.unsafeGetWithoutCapture(this.getCameraId())! const { x: cx, y: cy, z: cz } = unsafe__withoutCapture(() => this.getCamera())
const sx = info.point.x - screenBounds.x const sx = info.point.x - screenBounds.x
const sy = info.point.y - screenBounds.y const sy = info.point.y - screenBounds.y