remove dots in geometric shapes (#613)
This commit is contained in:
parent
15e3e9805f
commit
99dd67cd81
5 changed files with 21 additions and 5 deletions
|
@ -452,7 +452,10 @@ describe('TldrawTestApp', () => {
|
||||||
|
|
||||||
const prevA = app.shapes.map((shape) => shape.id)
|
const prevA = app.shapes.map((shape) => shape.id)
|
||||||
|
|
||||||
app.pointCanvas({ x: 0, y: 0 }).movePointer({ x: 100, y: 100 }).stopPointing()
|
app
|
||||||
|
.pointCanvas({ x: 0, y: 0 })
|
||||||
|
.movePointer({ x: 100, y: 100 })
|
||||||
|
.stopPointing('canvas', [100, 100])
|
||||||
|
|
||||||
const newIdA = app.shapes.map((shape) => shape.id).find((id) => !prevA.includes(id))!
|
const newIdA = app.shapes.map((shape) => shape.id).find((id) => !prevA.includes(id))!
|
||||||
const shapeA = app.getShape(newIdA)
|
const shapeA = app.getShape(newIdA)
|
||||||
|
@ -467,7 +470,10 @@ describe('TldrawTestApp', () => {
|
||||||
|
|
||||||
const prevB = app.shapes.map((shape) => shape.id)
|
const prevB = app.shapes.map((shape) => shape.id)
|
||||||
|
|
||||||
app.pointCanvas({ x: 0, y: 0 }).movePointer({ x: 100, y: 100 }).stopPointing()
|
app
|
||||||
|
.pointCanvas({ x: 0, y: 0 })
|
||||||
|
.movePointer({ x: 100, y: 100 })
|
||||||
|
.stopPointing('canvas', [100, 100])
|
||||||
|
|
||||||
const newIdB = app.shapes.map((shape) => shape.id).find((id) => !prevB.includes(id))!
|
const newIdB = app.shapes.map((shape) => shape.id).find((id) => !prevB.includes(id))!
|
||||||
const shapeB = app.getShape(newIdB)
|
const shapeB = app.getShape(newIdB)
|
||||||
|
|
|
@ -3181,7 +3181,6 @@ export class TldrawApp extends StateManager<TDSnapshot> {
|
||||||
onPointerMove: TLPointerEventHandler = (info, e) => {
|
onPointerMove: TLPointerEventHandler = (info, e) => {
|
||||||
this.previousPoint = this.currentPoint
|
this.previousPoint = this.currentPoint
|
||||||
this.updateInputs(info, e)
|
this.updateInputs(info, e)
|
||||||
|
|
||||||
if (this.isForcePanning && this.isPointing) {
|
if (this.isForcePanning && this.isPointing) {
|
||||||
this.onPan?.({ ...info, delta: Vec.neg(info.delta) }, e as unknown as WheelEvent)
|
this.onPan?.({ ...info, delta: Vec.neg(info.delta) }, e as unknown as WheelEvent)
|
||||||
return
|
return
|
||||||
|
|
|
@ -216,12 +216,13 @@ describe('Transform session', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('When creating with a transform session', () => {
|
describe('When creating with a transform session', () => {
|
||||||
it('Deletes the shape on undo', () => {
|
it.only('Deletes the shape on undo', () => {
|
||||||
const app = new TldrawTestApp()
|
const app = new TldrawTestApp()
|
||||||
.selectTool(TDShapeType.Rectangle)
|
.selectTool(TDShapeType.Rectangle)
|
||||||
.pointCanvas([0, 0])
|
.pointCanvas([0, 0])
|
||||||
|
.movePointer([5, 5])
|
||||||
.movePointer([10, 10])
|
.movePointer([10, 10])
|
||||||
.stopPointing()
|
.stopPointing('canvas', [10, 10])
|
||||||
|
|
||||||
expect(app.shapes.length).toBe(1)
|
expect(app.shapes.length).toBe(1)
|
||||||
|
|
||||||
|
|
|
@ -269,6 +269,10 @@ export class TransformSession extends BaseSession {
|
||||||
|
|
||||||
if (!hasUnlockedShapes) return
|
if (!hasUnlockedShapes) return
|
||||||
|
|
||||||
|
if (this.isCreate && Vec.dist(this.app.originPoint, this.app.currentPoint) < 2) {
|
||||||
|
return this.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
const beforeShapes: Record<string, TDShape | undefined> = {}
|
const beforeShapes: Record<string, TDShape | undefined> = {}
|
||||||
const afterShapes: Record<string, TDShape> = {}
|
const afterShapes: Record<string, TDShape> = {}
|
||||||
|
|
||||||
|
|
|
@ -228,6 +228,12 @@ export class TransformSingleSession extends BaseSession {
|
||||||
|
|
||||||
if (initialShape.isLocked) return
|
if (initialShape.isLocked) return
|
||||||
|
|
||||||
|
console.log('completed', this.app.originPoint, this.app.currentPoint)
|
||||||
|
|
||||||
|
if (this.isCreate && Vec.dist(this.app.originPoint, this.app.currentPoint) < 2) {
|
||||||
|
return this.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
const beforeShapes = {} as Record<string, Partial<TDShape> | undefined>
|
const beforeShapes = {} as Record<string, Partial<TDShape> | undefined>
|
||||||
const afterShapes = {} as Record<string, Partial<TDShape>>
|
const afterShapes = {} as Record<string, Partial<TDShape>>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue