Small optimization.

This commit is contained in:
Ophir LOJKINE 2013-10-05 12:34:36 +02:00
parent fa7b451b94
commit ea00e86965
3 changed files with 2485 additions and 8 deletions

View file

@ -127,7 +127,7 @@ Tools.toolHooks = [
tool.compiledListeners = compiled;
function compile (listener) { //closure
return (function(evt){
return (function listen (evt){
var x = evt.clientX + window.scrollX,
y = evt.clientY + window.scrollY;
listener(x,y,evt);

View file

@ -1,6 +1,12 @@
(function(){ //Code isolation
//Indicates the id of the line the user is currently drawing or an empty string while the user is not drawing
var curLineId = "",
curPoint = { //The data of the message that will be sent for every new point
'type' : 'point',
'line' : "",
'x' : 0,
'y' : 0
},
lastTime = performance.now(); //The time at which the last point was drawn
function startLine (x,y) {
@ -10,7 +16,10 @@
'type' : 'line',
'id' : curLineId
});
//Update the current point
curPoint.line = curLineId;
//Immediatly add a point to the line
continueLine(x,y);
}
@ -20,12 +29,8 @@
This allows the animation to be smother*/
if (curLineId !== "" &&
performance.now() - lastTime > 50) {
Tools.drawAndSend({
'type' : 'point',
'line' : curLineId,
'x' : x,
'y' : y
});
curPoint.x = x; curPoint.y = y;
Tools.drawAndSend(curPoint);
lastTime = performance.now();
}
}

File diff suppressed because it is too large Load diff