Skip to content

Commit

Permalink
Merge pull request #94 from AIFARMS/pradeepsen99.add-data-persistence
Browse files Browse the repository at this point in the history
fix: add in data persistence via mouse down
  • Loading branch information
pradeepsen99 authored Mar 21, 2024
2 parents 86a64e2 + de19f13 commit 6fc7291
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/ui_elements/Components/fabric_canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function FabricRender(props){
const play_redux = useSelector(state => state.play_status.play)
const image_data = image_data_store['data'][props.stream_num]

var save_data = (frame_number, reason) => {
const save_data = (frame_number, reason) => {
if(fabricCanvas){
console.log('SAVING DATA FOR FRAME', frame_number, reason)
updateFrameData(frame_number, fabricCanvas.getObjects())
Expand Down Expand Up @@ -105,7 +105,6 @@ export default function FabricRender(props){
});

temp_fabricCanvas.on('mouse:down', function(opt) {
save_data(frameToUpdate, "mouse_down")
var evt = opt.e;
if (evt.altKey === true) {
this.isDragging = true;
Expand All @@ -115,7 +114,6 @@ export default function FabricRender(props){
}
});
temp_fabricCanvas.on('mouse:move', function(opt) {
save_data(frameToUpdate, "mouse_move")
if (this.isDragging) {
var e = opt.e;
var vpt = this.viewportTransform;
Expand All @@ -127,8 +125,8 @@ export default function FabricRender(props){
}
});
temp_fabricCanvas.on('mouse:up', function(opt) {
save_data(frameToUpdate, "mouse_up")
if(this.objDrag){
updateFrameData(currframe_redux, temp_fabricCanvas.getObjects())
if(this.objDrag){
this.objDrag = false;
}
this.setViewportTransform(this.viewportTransform);
Expand All @@ -150,7 +148,7 @@ export default function FabricRender(props){
useEffect(() => {
if(fabricCanvas){
save_data(frameToUpdate, "frame_change")
setFrameToUpdate(currframe_redux)
setFrameToUpdate(currframe_redux)
var video = document.getElementsByTagName('video')[props.stream_num]
if(upload == true){
video.currentTime = (video.duration * ((currframe_redux+1)/metadata_redux['total_frames']))
Expand Down Expand Up @@ -238,4 +236,5 @@ export default function FabricRender(props){
</div>
</div>
)
//}
}

0 comments on commit 6fc7291

Please sign in to comment.