fix coordinates

This commit is contained in:
Jeff Emmett 2025-11-10 23:04:52 -08:00
parent 0fa1652f72
commit 229f4d6b41
1 changed files with 15 additions and 6 deletions

View File

@ -376,8 +376,11 @@ export function useAutomergeStoreV2({
const shapeFromStore = store.get(s.id) const shapeFromStore = store.get(s.id)
if (shapeFromStore && shapeFromStore.typeName === 'shape') { if (shapeFromStore && shapeFromStore.typeName === 'shape') {
// Preserve original x and y from the store shape data // Preserve original x and y from the store shape data
const originalX = s.x !== undefined && typeof s.x === 'number' && !isNaN(s.x) ? s.x : (shapeFromStore as any).x // Type assertion needed because s is TLRecord but we know it's a shape
const originalY = s.y !== undefined && typeof s.y === 'number' && !isNaN(s.y) ? s.y : (shapeFromStore as any).y const sAny = s as any
const shapeFromStoreAny = shapeFromStore as any
const originalX = sAny.x !== undefined && typeof sAny.x === 'number' && !isNaN(sAny.x) ? sAny.x : shapeFromStoreAny.x
const originalY = sAny.y !== undefined && typeof sAny.y === 'number' && !isNaN(sAny.y) ? sAny.y : shapeFromStoreAny.y
// Ensure x and y are preserved // Ensure x and y are preserved
if (typeof originalX === 'number' && !isNaN(originalX) && typeof originalY === 'number' && !isNaN(originalY)) { if (typeof originalX === 'number' && !isNaN(originalX) && typeof originalY === 'number' && !isNaN(originalY)) {
@ -440,8 +443,11 @@ export function useAutomergeStoreV2({
const shapeFromStore = store.get(s.id) const shapeFromStore = store.get(s.id)
if (shapeFromStore && shapeFromStore.typeName === 'shape') { if (shapeFromStore && shapeFromStore.typeName === 'shape') {
// Preserve original x and y from the store shape data // Preserve original x and y from the store shape data
const originalX = s.x !== undefined && typeof s.x === 'number' && !isNaN(s.x) ? s.x : (shapeFromStore as any).x // Type assertion needed because s is TLRecord but we know it's a shape
const originalY = s.y !== undefined && typeof s.y === 'number' && !isNaN(s.y) ? s.y : (shapeFromStore as any).y const sAny = s as any
const shapeFromStoreAny = shapeFromStore as any
const originalX = sAny.x !== undefined && typeof sAny.x === 'number' && !isNaN(sAny.x) ? sAny.x : shapeFromStoreAny.x
const originalY = sAny.y !== undefined && typeof sAny.y === 'number' && !isNaN(sAny.y) ? sAny.y : shapeFromStoreAny.y
// Ensure x and y are preserved // Ensure x and y are preserved
if (typeof originalX === 'number' && !isNaN(originalX) && typeof originalY === 'number' && !isNaN(originalY)) { if (typeof originalX === 'number' && !isNaN(originalX) && typeof originalY === 'number' && !isNaN(originalY)) {
@ -537,8 +543,11 @@ export function useAutomergeStoreV2({
const shapeFromStore = store.get(s.id) const shapeFromStore = store.get(s.id)
if (shapeFromStore && shapeFromStore.typeName === 'shape') { if (shapeFromStore && shapeFromStore.typeName === 'shape') {
// Preserve original x and y from the store shape data // Preserve original x and y from the store shape data
const originalX = s.x !== undefined && typeof s.x === 'number' && !isNaN(s.x) ? s.x : (shapeFromStore as any).x // Type assertion needed because s is TLRecord but we know it's a shape
const originalY = s.y !== undefined && typeof s.y === 'number' && !isNaN(s.y) ? s.y : (shapeFromStore as any).y const sAny = s as any
const shapeFromStoreAny = shapeFromStore as any
const originalX = sAny.x !== undefined && typeof sAny.x === 'number' && !isNaN(sAny.x) ? sAny.x : shapeFromStoreAny.x
const originalY = sAny.y !== undefined && typeof sAny.y === 'number' && !isNaN(sAny.y) ? sAny.y : shapeFromStoreAny.y
// Ensure x and y are preserved // Ensure x and y are preserved
if (typeof originalX === 'number' && !isNaN(originalX) && typeof originalY === 'number' && !isNaN(originalY)) { if (typeof originalX === 'number' && !isNaN(originalX) && typeof originalY === 'number' && !isNaN(originalY)) {