mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Convert ToolEvent type constants to Sg-style hyphenated lowercase strings.
This commit is contained in:
parent
ba7d2c0acf
commit
6619447aa1
3 changed files with 15 additions and 15 deletions
|
@ -23,7 +23,7 @@ var Tool = ToolHandler.extend(new function() {
|
||||||
var events = {
|
var events = {
|
||||||
dragstart: function(e) {
|
dragstart: function(e) {
|
||||||
curPoint = viewToArtwork(e, that._document);
|
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();
|
||||||
if (that.eventInterval != -1)
|
if (that.eventInterval != -1)
|
||||||
|
@ -34,7 +34,7 @@ var Tool = ToolHandler.extend(new function() {
|
||||||
drag: function(e) {
|
drag: function(e) {
|
||||||
if (e) curPoint = viewToArtwork(e, that._document);
|
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)
|
||||||
that._document.redraw();
|
that._document.redraw();
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ var 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',
|
that.onHandleEvent('mouse-up',
|
||||||
viewToArtwork(e, that._document), null, null);
|
viewToArtwork(e, that._document), null, null);
|
||||||
if (that.onMouseUp)
|
if (that.onMouseUp)
|
||||||
that._document.redraw();
|
that._document.redraw();
|
||||||
|
@ -51,7 +51,7 @@ var Tool = ToolHandler.extend(new function() {
|
||||||
},
|
},
|
||||||
mousemove: function(e) {
|
mousemove: function(e) {
|
||||||
if (!dragging) {
|
if (!dragging) {
|
||||||
that.onHandleEvent('MOUSE_MOVE',
|
that.onHandleEvent('mouse-move',
|
||||||
viewToArtwork(e, that._document), null, null);
|
viewToArtwork(e, that._document), null, null);
|
||||||
if (that.onMouseMove)
|
if (that.onMouseMove)
|
||||||
that._document.redraw();
|
that._document.redraw();
|
||||||
|
|
|
@ -182,8 +182,8 @@ ToolEvent = Base.extend({
|
||||||
*/
|
*/
|
||||||
getCount: function() {
|
getCount: function() {
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case 'MOUSE_DOWN':
|
case 'mouse-down':
|
||||||
case 'MOUSE_UP':
|
case 'mouse-up':
|
||||||
// Return downCount for both mouse down and up, since
|
// Return downCount for both mouse down and up, since
|
||||||
// the count is the same.
|
// the count is the same.
|
||||||
return this.tool.downCount;
|
return this.tool.downCount;
|
||||||
|
@ -194,8 +194,8 @@ ToolEvent = Base.extend({
|
||||||
|
|
||||||
setCount: function(count) {
|
setCount: function(count) {
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
case 'MOUSE_DOWN':
|
case 'mouse-down':
|
||||||
case 'MOUSE_UP':
|
case 'mouse-up':
|
||||||
this.tool.downCount = count;
|
this.tool.downCount = count;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -83,12 +83,12 @@ var ToolHandler = Base.extend({
|
||||||
this.lastPoint = this.point;
|
this.lastPoint = this.point;
|
||||||
this.point = pt;
|
this.point = pt;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'MOUSE_DOWN':
|
case 'mouse-down':
|
||||||
this.lastPoint = this.downPoint;
|
this.lastPoint = this.downPoint;
|
||||||
this.downPoint = this.point;
|
this.downPoint = this.point;
|
||||||
this.downCount++;
|
this.downCount++;
|
||||||
break;
|
break;
|
||||||
case 'MOUSE_UP':
|
case 'mouse-up':
|
||||||
// Mouse up events return the down point for last point,
|
// Mouse up events return the down point for last point,
|
||||||
// so delta is spanning over the whole drag.
|
// so delta is spanning over the whole drag.
|
||||||
this.lastPoint = this.downPoint;
|
this.lastPoint = this.downPoint;
|
||||||
|
@ -104,12 +104,12 @@ var ToolHandler = Base.extend({
|
||||||
|
|
||||||
onHandleEvent: function(type, pt, modifiers) {
|
onHandleEvent: function(type, pt, modifiers) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'MOUSE_DOWN':
|
case 'mouse-down':
|
||||||
this.updateEvent(type, pt, null, null, true, false, false);
|
this.updateEvent(type, pt, null, null, true, false, false);
|
||||||
if (this.onMouseDown)
|
if (this.onMouseDown)
|
||||||
this.onMouseDown(new ToolEvent(this, type, modifiers));
|
this.onMouseDown(new ToolEvent(this, type, modifiers));
|
||||||
break;
|
break;
|
||||||
case 'MOUSE_DRAG':
|
case 'mouse-drag':
|
||||||
// In order for idleInterval drag events to work, we need to
|
// In order for idleInterval drag events to work, we need to
|
||||||
// not check the first call for a change of position.
|
// not check the first call for a change of position.
|
||||||
// Subsequent calls required by min/maxDistance functionality
|
// Subsequent calls required by min/maxDistance functionality
|
||||||
|
@ -129,11 +129,11 @@ var ToolHandler = Base.extend({
|
||||||
this.matchMaxDistance = true;
|
this.matchMaxDistance = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'MOUSE_UP':
|
case 'mouse-up':
|
||||||
// If the last mouse drag happened in a different place, call
|
// If the last mouse drag happened in a different place, call
|
||||||
// mouse drag first, then mouse up.
|
// mouse drag first, then mouse up.
|
||||||
if ((this.point.x != pt.x || this.point.y != pt.y)
|
if ((this.point.x != pt.x || this.point.y != pt.y)
|
||||||
&& this.updateEvent('MOUSE_DRAG', pt, this.minDistance,
|
&& this.updateEvent('mouse-drag', pt, this.minDistance,
|
||||||
this.maxDistance, false, false, false)) {
|
this.maxDistance, false, false, false)) {
|
||||||
if (this.onMouseDrag)
|
if (this.onMouseDrag)
|
||||||
this.onMouseDrag(new ToolEvent(this, type, modifiers));
|
this.onMouseDrag(new ToolEvent(this, type, modifiers));
|
||||||
|
@ -146,7 +146,7 @@ var ToolHandler = Base.extend({
|
||||||
this.updateEvent(type, pt, null, null, true, false, false);
|
this.updateEvent(type, pt, null, null, true, false, false);
|
||||||
this.firstMove = true;
|
this.firstMove = true;
|
||||||
break;
|
break;
|
||||||
case 'MOUSE_MOVE':
|
case 'mouse-move':
|
||||||
while (this.updateEvent(type, pt, this.minDistance,
|
while (this.updateEvent(type, pt, this.minDistance,
|
||||||
this.maxDistance, this.firstMove, true, false)) {
|
this.maxDistance, this.firstMove, true, false)) {
|
||||||
if (this.onMouseMove)
|
if (this.onMouseMove)
|
||||||
|
|
Loading…
Reference in a new issue