Commit a2aa0e3c authored by marioromera's avatar marioromera
Browse files

fix some stuff

parent 9f4b24c5
......@@ -9,7 +9,6 @@ const MARGIN = 20;
const createEmptyframe = () => ({
pathData: [],
from: undefined,
id: 'frameId' + Date.now() * Math.random(),
});
export default function Drawing(svgId) {
this.sessions = [];
......@@ -133,36 +132,22 @@ export default function Drawing(svgId) {
};
this.drawframes = (frames) => {
clearInterval(this.sessionInterval);
let frame = 0;
this.sessionInterval = setInterval(() => {
console.log('Drawing frame', frame);
const f = frames[frame];
let frame = frames.length - 1;
if (!f) return;
const f = frames[frame];
const overallConnected = state.data.overallConnected;
if (!f) return;
const colorIndex = overallConnected.indexOf(f.from);
const overallConnected = state.data.overallConnected;
this.drawLine(f.pathData, colorIndex, frame);
const colorIndex = overallConnected.indexOf(f.from);
frame = frame + 1;
setTimeout(() => {
if (frame === frames.length) {
console.log('Restarting');
this.group.selectAll('path').remove();
frame = 0;
this.drawframes(frames);
}
}, 500);
}, 1000);
this.drawLine(f.pathData, colorIndex, frame);
};
this.drawLine = (pathData, colorIndex, frame) => {
const group = frame === undefined ? this.liveDrawingG : this.group;
this.path = group
.append('path') // start a new line
.data([pathData])
......@@ -218,7 +203,6 @@ export default function Drawing(svgId) {
updateGossipData('frames', [...state.data.frames, this.session]);
this.$myTurn.next(false);
this.liveDrawingG.selectAll('path').remove();
// redraw the line after simplification
......@@ -264,8 +248,8 @@ export default function Drawing(svgId) {
.attr('height', this.height)
.attr('class', 'drawing-canvas-background');
this.group = this.svg.append('g').attr('id', 'group');
this.liveDrawingG = this.svg.append('g').attr('id', 'group');
this.group = this.svg.append('g');
this.liveDrawingG = this.svg.append('g');
this.myTurnG = this.svg
.append('g')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment