remove dots in geometric shapes (#613)

This commit is contained in:
Steve Ruiz 2022-03-09 13:04:39 +00:00 committed by GitHub
parent 15e3e9805f
commit 99dd67cd81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 5 deletions

View file

@ -452,7 +452,10 @@ describe('TldrawTestApp', () => {
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 shapeA = app.getShape(newIdA)
@ -467,7 +470,10 @@ describe('TldrawTestApp', () => {
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 shapeB = app.getShape(newIdB)

View file

@ -3181,7 +3181,6 @@ export class TldrawApp extends StateManager<TDSnapshot> {
onPointerMove: TLPointerEventHandler = (info, e) => {
this.previousPoint = this.currentPoint
this.updateInputs(info, e)
if (this.isForcePanning && this.isPointing) {
this.onPan?.({ ...info, delta: Vec.neg(info.delta) }, e as unknown as WheelEvent)
return

View file

@ -216,12 +216,13 @@ describe('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()
.selectTool(TDShapeType.Rectangle)
.pointCanvas([0, 0])
.movePointer([5, 5])
.movePointer([10, 10])
.stopPointing()
.stopPointing('canvas', [10, 10])
expect(app.shapes.length).toBe(1)

View file

@ -269,6 +269,10 @@ export class TransformSession extends BaseSession {
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 afterShapes: Record<string, TDShape> = {}

View file

@ -228,6 +228,12 @@ export class TransformSingleSession extends BaseSession {
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 afterShapes = {} as Record<string, Partial<TDShape>>