mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-04 03:45:58 -05:00
Fix mistakes in Tool.js
This commit is contained in:
parent
1261dc03df
commit
14b8452bad
1 changed files with 7 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
Tool = ToolHandler.extend(new function() {
|
Tool = ToolHandler.extend(new function() {
|
||||||
function viewToArtwork(event, document) {
|
function viewToArtwork(event, document) {
|
||||||
var point = Point.read(event.offset.x, event.offset.y);
|
var point = Point.create(event.offset.x, event.offset.y);
|
||||||
// TODO: always the active view?
|
// TODO: always the active view?
|
||||||
return document.activeView.viewToArtwork(point);
|
return document.activeView.viewToArtwork(point);
|
||||||
};
|
};
|
||||||
|
@ -22,7 +22,7 @@ Tool = ToolHandler.extend(new function() {
|
||||||
var dragging = false;
|
var dragging = false;
|
||||||
var events = {
|
var events = {
|
||||||
dragstart: function(e) {
|
dragstart: function(e) {
|
||||||
curPoint = viewToArtwork(e);//new Point(e.offset);
|
curPoint = viewToArtwork(e, that._document);
|
||||||
that.onHandleEvent('MOUSE_DOWN', curPoint, null, null);
|
that.onHandleEvent('MOUSE_DOWN', curPoint, null, null);
|
||||||
if (that.onMouseDown)
|
if (that.onMouseDown)
|
||||||
that._document.redraw();
|
that._document.redraw();
|
||||||
|
@ -31,7 +31,7 @@ Tool = ToolHandler.extend(new function() {
|
||||||
dragging = true;
|
dragging = true;
|
||||||
},
|
},
|
||||||
drag: function(e) {
|
drag: function(e) {
|
||||||
if (e) curPoint = viewToArtwork(e);//new Point(e.offset);
|
if (e) curPoint = viewToArtwork(e, that._document);
|
||||||
if (curPoint) {
|
if (curPoint) {
|
||||||
that.onHandleEvent('MOUSE_DRAG', curPoint, null, null);
|
that.onHandleEvent('MOUSE_DRAG', curPoint, null, null);
|
||||||
if (that.onMouseDrag)
|
if (that.onMouseDrag)
|
||||||
|
@ -42,14 +42,16 @@ Tool = ToolHandler.extend(new function() {
|
||||||
curPoint = null;
|
curPoint = null;
|
||||||
if (this.eventInterval != -1)
|
if (this.eventInterval != -1)
|
||||||
clearInterval(this.intervalId);
|
clearInterval(this.intervalId);
|
||||||
that.onHandleEvent('MOUSE_UP', viewToArtwork(e), null, null);
|
that.onHandleEvent('MOUSE_UP',
|
||||||
|
viewToArtwork(e, that._document), null, null);
|
||||||
if (that.onMouseUp)
|
if (that.onMouseUp)
|
||||||
that._document.redraw();
|
that._document.redraw();
|
||||||
dragging = false;
|
dragging = false;
|
||||||
},
|
},
|
||||||
mousemove: function(e) {
|
mousemove: function(e) {
|
||||||
if (!dragging) {
|
if (!dragging) {
|
||||||
that.onHandleEvent('MOUSE_MOVE', viewToArtwork(e), null, null);
|
that.onHandleEvent('MOUSE_MOVE',
|
||||||
|
viewToArtwork(e, that._document), null, null);
|
||||||
if (that.onMouseMove)
|
if (that.onMouseMove)
|
||||||
that._document.redraw();
|
that._document.redraw();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue