Multiplayer: a little bit better mouse playback

main
Isaiah Odhner 2014-12-08 21:43:21 -05:00
parent 30f70bf1de
commit 25d1008030
2 changed files with 12 additions and 28 deletions

View File

@ -35,6 +35,7 @@ You can also install it as a Chrome app.
Start up a session at
[jspaint.ml/#session:bad455](http://1j01.github.io/jspaint/#session:bad455)
and send the link to your friends!
It isn't perfectly seamless, and you may lose your drawing or be interrupted.
#### Possible improvements include:

View File

@ -225,7 +225,6 @@
$canvas.triggerHandler(e, ["synthetic"]);
$G.triggerHandler(e, ["synthetic"]);
}
mouse_operations = [];
};
img.src = uri;
}
@ -238,45 +237,29 @@
$canvas_area.on("mousedown.session-hook", "*", function(e, synthetic){
console.log(e.type, "| synthetic?", synthetic);
if(synthetic){ return; }
// If you're using the fill tool
if(selected_tool.name.match(/Fill/)){
// Sync immediately
sync();
}else{
if(!synthetic){
mouse_operations = [e];
}
/*
mouse_operations = [];
var canvas_rect = canvas.getBoundingClientRect();
mouse_operations.push({
type: "mousedown",
x: e.clientX - canvas_rect.left,
y: e.clientY - canvas_rect.top,
});*/
mouse_operations = [e];
var mousemove = function(e, synthetic){
console.log(e.type, "| synthetic?", synthetic);
if(!synthetic){
mouse_operations.push(e);
}
/*var canvas_rect = canvas.getBoundingClientRect();
mouse_operations.push({
type: "mousemove",
x: e.clientX - canvas_rect.left,
y: e.clientY - canvas_rect.top,
});*/
if(synthetic){ return; }
mouse_operations.push(e);
};
$G.on("mousemove.session-hook", mousemove);
$G.one("mouseup.session-hook", function(e, synthetic){
console.log(e.type, "| synthetic?", synthetic);
if(synthetic){ return; }
$G.off("mousemove.session-hook", mousemove);
/// // ///// Clear the mouse operations unless this event is synthesized
///// / // // in the place that's about to try to use the mouse operations
if(!synthetic){
///// mouse_operations = [];
// a change might have occured
sync();
}
// a change might have occured
sync();
});
}
});