Ver código fonte

mark where to go next

Peng Xiao 3 anos atrás
pai
commit
9097084a21

+ 1 - 0
tldraw/packages/core/src/lib/TLApp/TLApp.ts

@@ -505,6 +505,7 @@ export class TLApp<
     return Vec.mul(Vec.add(point, camera.point), camera.zoom)
   }
 
+  @computed
   get currentGrid() {
     const { zoom } = this.viewport.camera
     if (zoom < 0.15) {

+ 9 - 1
tldraw/packages/core/src/lib/TLPage/TLPage.ts

@@ -1,5 +1,5 @@
 /* eslint-disable @typescript-eslint/no-explicit-any */
-import { action, observable, makeObservable, computed, observe } from 'mobx'
+import { action, observable, makeObservable, computed, observe, reaction, toJS } from 'mobx'
 import { TLBinding, TLEventMap, TLResizeCorner } from '~types'
 import type { TLApp, TLShape, TLShapeModel } from '~lib'
 import { BoundsUtils, deepCopy } from '~utils'
@@ -28,6 +28,14 @@ export class TLPage<S extends TLShape = TLShape, E extends TLEventMap = TLEventM
     this.app = app
     this.addShapes(...shapes)
     makeObservable(this)
+
+    reaction(
+      () => this.shapes.map(shape => toJS(shape.props)),
+      // todo: recalculate binding positions
+      (curr, prev) => {
+        console.log(curr, prev)
+      }
+    )
   }
 
   app: TLApp<S, E>

+ 0 - 7
tldraw/packages/core/src/lib/tools/TLLineTool/states/CreatingState.tsx

@@ -130,13 +130,6 @@ export class CreatingState<
 
       const hasStartBinding = this.app.currentPage.bindings[this.newStartBindingId] !== undefined
 
-      console.log(
-        isInsideShape,
-        startTarget.hitTestPoint(Vec.add(next.shape.point, endHandle.point)),
-        endHandle.point,
-        next.shape.point
-      )
-
       // Don't bind the start handle if both handles are inside of the target shape.
       if (!modKey && !startTarget.hitTestPoint(Vec.add(next.shape.point, endHandle.point))) {
         nextStartBinding = this.findBindingPoint(