mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Fix various refactoring errors.
This commit is contained in:
parent
e8033730c8
commit
83373576f2
1 changed files with 13 additions and 14 deletions
|
@ -120,12 +120,10 @@ var DocumentView = this.DocumentView = Base.extend({
|
||||||
draw: function() {
|
draw: function() {
|
||||||
if (this._stats)
|
if (this._stats)
|
||||||
this._stats.update();
|
this._stats.update();
|
||||||
|
|
||||||
// Initial tests conclude that clearing the canvas using clearRect
|
// Initial tests conclude that clearing the canvas using clearRect
|
||||||
// is always faster than setting canvas.width = canvas.width
|
// is always faster than setting canvas.width = canvas.width
|
||||||
// http://jsperf.com/clearrect-vs-setting-width/7
|
// http://jsperf.com/clearrect-vs-setting-width/7
|
||||||
this._context.clearRect(0, 0, this._size.width + 1, this._size.height + 1);
|
this._context.clearRect(0, 0, this._size.width + 1, this._size.height + 1);
|
||||||
|
|
||||||
this._document.draw(this._context);
|
this._document.draw(this._context);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -170,6 +168,7 @@ var DocumentView = this.DocumentView = Base.extend({
|
||||||
_createEvents: function() {
|
_createEvents: function() {
|
||||||
var scope = this._document._scope,
|
var scope = this._document._scope,
|
||||||
tool,
|
tool,
|
||||||
|
timer,
|
||||||
curPoint,
|
curPoint,
|
||||||
dragging = false,
|
dragging = false,
|
||||||
that = this;
|
that = this;
|
||||||
|
@ -184,10 +183,9 @@ var DocumentView = this.DocumentView = Base.extend({
|
||||||
curPoint = viewToArtwork(event);
|
curPoint = viewToArtwork(event);
|
||||||
tool.onHandleEvent('mousedown', curPoint, event);
|
tool.onHandleEvent('mousedown', curPoint, event);
|
||||||
if (tool.onMouseDown)
|
if (tool.onMouseDown)
|
||||||
that._document.redraw();
|
that.draw();
|
||||||
if (that.eventInterval != null) {
|
if (tool.eventInterval != null)
|
||||||
this.timer = setInterval(events.mousemove, that.eventInterval);
|
timer = setInterval(events.mousemove, tool.eventInterval);
|
||||||
}
|
|
||||||
dragging = true;
|
dragging = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,27 +203,28 @@ var DocumentView = this.DocumentView = Base.extend({
|
||||||
if (curPoint)
|
if (curPoint)
|
||||||
tool.onHandleEvent('mousedrag', curPoint, event);
|
tool.onHandleEvent('mousedrag', curPoint, event);
|
||||||
if (tool.onMouseDrag)
|
if (tool.onMouseDrag)
|
||||||
that._document.redraw();
|
that.draw();
|
||||||
// PORT: If there is only an onMouseMove handler, also call it when
|
// PORT: If there is only an onMouseMove handler, also call it when
|
||||||
// the user is dragging:
|
// the user is dragging:
|
||||||
} else if (!dragging || onlyMove) {
|
} else if (!dragging || onlyMove) {
|
||||||
tool.onHandleEvent('mousemove', point, event);
|
tool.onHandleEvent('mousemove', point, event);
|
||||||
if (tool.onMouseMove)
|
if (tool.onMouseMove)
|
||||||
that._document.redraw();
|
that.draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mouseup(event) {
|
function mouseup(event) {
|
||||||
if (!dragging || !tool) {
|
if (!dragging)
|
||||||
dragging = false;
|
return;
|
||||||
|
dragging = false;
|
||||||
|
if (!tool)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
curPoint = null;
|
curPoint = null;
|
||||||
if (that.eventInterval != null)
|
if (tool.eventInterval != null)
|
||||||
clearInterval(this.timer);
|
timer = clearInterval(timer);
|
||||||
tool.onHandleEvent('mouseup', viewToArtwork(event), event);
|
tool.onHandleEvent('mouseup', viewToArtwork(event), event);
|
||||||
if (tool.onMouseUp)
|
if (tool.onMouseUp)
|
||||||
that._document.redraw();
|
that.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue