mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Tool: add support for Tool#eventInterval
This commit is contained in:
parent
a633b2a066
commit
e36ea0c2e3
1 changed files with 18 additions and 6 deletions
|
@ -3,25 +3,37 @@ Tool = ToolHandler.extend({
|
||||||
|
|
||||||
initialize: function(handlers, doc) {
|
initialize: function(handlers, doc) {
|
||||||
this.base(handlers);
|
this.base(handlers);
|
||||||
|
if(Paper.document)
|
||||||
|
this.document = Paper.document;
|
||||||
},
|
},
|
||||||
|
|
||||||
setDocument: function(doc) {
|
setDocument: function(doc) {
|
||||||
this._document = doc;
|
this._document = doc;
|
||||||
var that = this;
|
var that = this, curPoint;
|
||||||
$(doc.canvas).addEvents({
|
var events = {
|
||||||
mousedown: function(e) {
|
mousedown: function(e) {
|
||||||
that.onHandleEvent('MOUSE_DOWN', new Point(e.offset), null, null);
|
curPoint = new Point(e.offset);
|
||||||
|
that.onHandleEvent('MOUSE_DOWN', curPoint, null, null);
|
||||||
that._document.redraw();
|
that._document.redraw();
|
||||||
|
if(that.eventInterval != -1)
|
||||||
|
this.intervalId = setInterval(events.drag, that.eventInterval);
|
||||||
},
|
},
|
||||||
drag: function(e) {
|
drag: function(e) {
|
||||||
that.onHandleEvent('MOUSE_DRAG', new Point(e.offset), null, null);
|
if(e) curPoint = new Point(e.offset);
|
||||||
that._document.redraw();
|
if(curPoint) {
|
||||||
|
that.onHandleEvent('MOUSE_DRAG', curPoint, null, null);
|
||||||
|
that._document.redraw();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
dragend: function(e) {
|
dragend: function(e) {
|
||||||
|
curPoint = null;
|
||||||
|
if(this.eventInterval != -1)
|
||||||
|
clearInterval(this.intervalId);
|
||||||
that.onHandleEvent('MOUSE_UP', new Point(e.offset), null, null);
|
that.onHandleEvent('MOUSE_UP', new Point(e.offset), null, null);
|
||||||
that._document.redraw();
|
that._document.redraw();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
$(doc.canvas).addEvents(events);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue