more UI updates
This commit is contained in:
@@ -79,9 +79,8 @@ class Shape {
|
||||
|
||||
createOrDraw() {
|
||||
if(this.id) return
|
||||
const points = this.pointsFromModel()
|
||||
if(points && points.length)
|
||||
this.doCreate(points)
|
||||
if(this.points && this.points.length)
|
||||
this.doCreate(this.points)
|
||||
else
|
||||
this.draw()
|
||||
}
|
||||
@@ -111,9 +110,11 @@ class Shape {
|
||||
|
||||
setPoints(points) {
|
||||
this.points = points
|
||||
if (points !== null && points.length) {
|
||||
if (points === null || !points.length)
|
||||
this.delete()
|
||||
else {
|
||||
if (this.id === null)
|
||||
this.doCreate(points)
|
||||
this.doCreate()
|
||||
else {
|
||||
const s = this.tvShape();
|
||||
if (!dragging) {
|
||||
@@ -129,7 +130,6 @@ class Shape {
|
||||
}
|
||||
}
|
||||
}
|
||||
// todo delete if points is null or empty?
|
||||
}
|
||||
|
||||
|
||||
@@ -163,8 +163,6 @@ class Shape {
|
||||
try {
|
||||
deleteShapeId(this.id)
|
||||
this.id = null
|
||||
} catch (e) {
|
||||
throw e
|
||||
} finally {
|
||||
this.lock--
|
||||
}
|
||||
@@ -261,7 +259,7 @@ class ShapeTVCallbacks {
|
||||
this.shape = shape
|
||||
}
|
||||
|
||||
onCreate(shapeId, points, props) {
|
||||
onCreate(shapeId, _tvShape, points, props) {
|
||||
if( this.shape.id )
|
||||
throw Error(`Created a shape ${shapeId} where one already existed ${this.shape.id}`)
|
||||
this.shape.id = shapeId
|
||||
@@ -269,13 +267,13 @@ class ShapeTVCallbacks {
|
||||
invokeCallback(this.shape, 'onCreate', points, props)
|
||||
}
|
||||
|
||||
onPoints(shapeId, points) {
|
||||
onPoints(shapeId, _tvShape, points) {
|
||||
this.shape.points = points
|
||||
this.shape.onPoints(points)
|
||||
this.shape.onDirtyModel(this.shape.pointsToModel)
|
||||
}
|
||||
|
||||
onProps(shapeId, props) {
|
||||
onProps(shapeId, _tvShape, props) {
|
||||
this.shape.props = props
|
||||
this.shape.onProps(props)
|
||||
this.shape.onDirtyModel(this.shape.propsToModel)
|
||||
@@ -301,35 +299,35 @@ class ShapeTVCallbacks {
|
||||
invokeCallback(this.shape, 'onAddPoint')
|
||||
}
|
||||
|
||||
onMove(_shapeId, points) {
|
||||
onMove(_shapeId, _tvShape, points) {
|
||||
if( this.shape.lock ) return
|
||||
invokeCallback(this.shape, 'onMove',points)
|
||||
}
|
||||
|
||||
onDrag(_shapeId, points) {
|
||||
onDrag(_shapeId, _tvShape, points) {
|
||||
if( this.shape.lock ) return
|
||||
invokeCallback(this.shape, 'onDrag', points)
|
||||
}
|
||||
|
||||
onHide(_shapeId, props) {
|
||||
onHide(_shapeId, _tvShape, props) {
|
||||
if( this.shape.lock ) return
|
||||
invokeCallback(this.shape, 'onHide',props)
|
||||
}
|
||||
|
||||
onShow(_shapeId, props) {
|
||||
onShow(_shapeId, _tvShape, props) {
|
||||
if( this.shape.lock ) return
|
||||
invokeCallback(this.shape, 'onShow',props)
|
||||
}
|
||||
|
||||
onClick(_shapeId) {
|
||||
onClick(_shapeId, _tvShape) {
|
||||
if( this.shape.lock ) return
|
||||
invokeCallback(this.shape, 'onClick')
|
||||
}
|
||||
|
||||
onDelete(_shapeId, props) {
|
||||
onDelete(shapeId) {
|
||||
this.shape.id = null
|
||||
if( this.shape.lock ) return
|
||||
invokeCallback(this.shape, 'onDelete',props)
|
||||
invokeCallback(this.shape, 'onDelete', shapeId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user