Skip to content

Commit

Permalink
[annotations] Fix multiple annotations moving
Browse files Browse the repository at this point in the history
  • Loading branch information
frankrousseau committed Oct 18, 2022
1 parent 867c90c commit 08a266f
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions src/components/mixins/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,22 +253,26 @@ export const annotationMixin = {
},

addToUpdates (obj) {
this.markLastAnnotationTime()
this.setObjectData(obj)
this.addToUpdatesSerializedObject(obj.serialize())
},

addToUpdatesSerializedObject (obj) {
this.markLastAnnotationTime()
const currentTime = this.getCurrentTime()
const updates = this.updates.find(a => a.time === currentTime)
if (updates) {
updates.drawing.objects = updates.drawing.objects.filter(
o => o.id !== obj.id
)
updates.drawing.objects.push(obj.serialize())
updates.drawing.objects.push(obj)
} else {
this.updates.push({
time: currentTime,
drawing: { objects: [obj.serialize()] }
drawing: { objects: [obj] }
})
}
this.postAnnotationUpdate(currentTime, obj.serialize())
this.postAnnotationUpdate(currentTime, obj)
},

postAnnotationUpdate (currentTime, obj) {
Expand Down Expand Up @@ -574,8 +578,23 @@ export const annotationMixin = {
},

onObjectMoved (obj) {
this.addToUpdates(obj.target)
this.saveAnnotations()
if (!obj.target._objects) {
this.addToUpdates(obj.target)
this.saveAnnotations()
} else {
obj.target._objects.forEach(o => {
const oo = this.getObjectById(o.id)
this.setObjectData(oo)
const targetObj = oo.serialize()
targetObj.left =
obj.target.left + Math.round(obj.target.width / 2) + o.left
targetObj.top =
obj.target.top + Math.round(obj.target.height / 2) + o.top
this.setObjectData(targetObj)
this.addToUpdatesSerializedObject(targetObj)
})
this.saveAnnotations()
}
},

fadeObject (obj) {
Expand Down

0 comments on commit 08a266f

Please sign in to comment.