mirror of
https://github.com/konvajs/konva.git
synced 2025-09-19 02:37:59 +08:00
changed getUserPosition to getPointerPosition, and setUserPosition to setPointerPosition
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
var dd = Kinetic.DD, node = dd.node;
|
var dd = Kinetic.DD, node = dd.node;
|
||||||
|
|
||||||
if(node) {
|
if(node) {
|
||||||
var pos = node.getStage().getUserPosition();
|
var pos = node.getStage().getPointerPosition();
|
||||||
var dbf = node.attrs.dragBoundFunc;
|
var dbf = node.attrs.dragBoundFunc;
|
||||||
|
|
||||||
var newNodePos = {
|
var newNodePos = {
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
that = this,
|
that = this,
|
||||||
stage = this.getStage(),
|
stage = this.getStage(),
|
||||||
layer = this.getLayer(),
|
layer = this.getLayer(),
|
||||||
pos = stage.getUserPosition();
|
pos = stage.getPointerPosition();
|
||||||
|
|
||||||
if(pos) {
|
if(pos) {
|
||||||
var m = this.getTransform().getTranslation(), ap = this.getAbsolutePosition(), nodeType = this.nodeType, container;
|
var m = this.getTransform().getTranslation(), ap = this.getAbsolutePosition(), nodeType = this.nodeType, container;
|
||||||
|
@@ -648,7 +648,7 @@
|
|||||||
var classType = this.shapeType || this.nodeType;
|
var classType = this.shapeType || this.nodeType;
|
||||||
var node = new Kinetic[classType](this.attrs);
|
var node = new Kinetic[classType](this.attrs);
|
||||||
|
|
||||||
// copy over user listeners
|
// copy over listeners
|
||||||
for(var key in this.eventListeners) {
|
for(var key in this.eventListeners) {
|
||||||
var allListeners = this.eventListeners[key];
|
var allListeners = this.eventListeners[key];
|
||||||
var len = allListeners.length;
|
var len = allListeners.length;
|
||||||
|
36
src/Stage.js
36
src/Stage.js
@@ -138,11 +138,11 @@
|
|||||||
return this.touchPos;
|
return this.touchPos;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get user position which can be a touc position or mouse position
|
* get pointer position which can be a touc position or mouse position
|
||||||
* @name getUserPosition
|
* @name getPointerPosition
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @methodOf Kinetic.Stage.prototype
|
||||||
*/
|
*/
|
||||||
getUserPosition: function() {
|
getPointerPosition: function() {
|
||||||
return this.getTouchPosition() || this.getMousePosition();
|
return this.getTouchPosition() || this.getMousePosition();
|
||||||
},
|
},
|
||||||
getStage: function() {
|
getStage: function() {
|
||||||
@@ -283,7 +283,7 @@
|
|||||||
|
|
||||||
this.bufferCanvas.setSize(width, height, 1);
|
this.bufferCanvas.setSize(width, height, 1);
|
||||||
this.hitCanvas.setSize(width, height);
|
this.hitCanvas.setSize(width, height);
|
||||||
// set user defined layer dimensions
|
// set pointer defined layer dimensions
|
||||||
var layers = this.children;
|
var layers = this.children;
|
||||||
for(var n = 0; n < layers.length; n++) {
|
for(var n = 0; n < layers.length; n++) {
|
||||||
var layer = layers[n];
|
var layer = layers[n];
|
||||||
@@ -325,7 +325,7 @@
|
|||||||
var dragLayer = this.dragLayer;
|
var dragLayer = this.dragLayer;
|
||||||
return dragLayer && dragLayer.getStage();
|
return dragLayer && dragLayer.getStage();
|
||||||
},
|
},
|
||||||
_setUserPosition: function(evt) {
|
_setPointerPosition: function(evt) {
|
||||||
if(!evt) {
|
if(!evt) {
|
||||||
evt = window.event;
|
evt = window.event;
|
||||||
}
|
}
|
||||||
@@ -347,7 +347,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
_mouseout: function(evt) {
|
_mouseout: function(evt) {
|
||||||
this._setUserPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
var dd = Kinetic.DD;
|
var dd = Kinetic.DD;
|
||||||
// if there's a current target shape, run mouseout handlers
|
// if there's a current target shape, run mouseout handlers
|
||||||
var targetShape = this.targetShape;
|
var targetShape = this.targetShape;
|
||||||
@@ -359,9 +359,9 @@
|
|||||||
this.mousePos = undefined;
|
this.mousePos = undefined;
|
||||||
},
|
},
|
||||||
_mousemove: function(evt) {
|
_mousemove: function(evt) {
|
||||||
this._setUserPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
var dd = Kinetic.DD;
|
var dd = Kinetic.DD;
|
||||||
var obj = this.getIntersection(this.getUserPosition());
|
var obj = this.getIntersection(this.getPointerPosition());
|
||||||
|
|
||||||
if(obj) {
|
if(obj) {
|
||||||
var shape = obj.shape;
|
var shape = obj.shape;
|
||||||
@@ -397,8 +397,8 @@
|
|||||||
},
|
},
|
||||||
_mousedown: function(evt) {
|
_mousedown: function(evt) {
|
||||||
var obj, dd = Kinetic.DD;
|
var obj, dd = Kinetic.DD;
|
||||||
this._setUserPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
obj = this.getIntersection(this.getUserPosition());
|
obj = this.getIntersection(this.getPointerPosition());
|
||||||
if(obj && obj.shape) {
|
if(obj && obj.shape) {
|
||||||
var shape = obj.shape;
|
var shape = obj.shape;
|
||||||
this.clickStart = true;
|
this.clickStart = true;
|
||||||
@@ -411,10 +411,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
_mouseup: function(evt) {
|
_mouseup: function(evt) {
|
||||||
this._setUserPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
var that = this,
|
var that = this,
|
||||||
dd = Kinetic.DD,
|
dd = Kinetic.DD,
|
||||||
obj = this.getIntersection(this.getUserPosition());
|
obj = this.getIntersection(this.getPointerPosition());
|
||||||
|
|
||||||
if(obj && obj.shape) {
|
if(obj && obj.shape) {
|
||||||
var shape = obj.shape;
|
var shape = obj.shape;
|
||||||
@@ -444,9 +444,9 @@
|
|||||||
_touchstart: function(evt) {
|
_touchstart: function(evt) {
|
||||||
var obj, dd = Kinetic.DD;
|
var obj, dd = Kinetic.DD;
|
||||||
|
|
||||||
this._setUserPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
obj = this.getIntersection(this.getUserPosition());
|
obj = this.getIntersection(this.getPointerPosition());
|
||||||
|
|
||||||
if(obj && obj.shape) {
|
if(obj && obj.shape) {
|
||||||
var shape = obj.shape;
|
var shape = obj.shape;
|
||||||
@@ -460,8 +460,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
_touchend: function(evt) {
|
_touchend: function(evt) {
|
||||||
this._setUserPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
var that = this, dd = Kinetic.DD, obj = this.getIntersection(this.getUserPosition());
|
var that = this, dd = Kinetic.DD, obj = this.getIntersection(this.getPointerPosition());
|
||||||
|
|
||||||
if(obj && obj.shape) {
|
if(obj && obj.shape) {
|
||||||
var shape = obj.shape;
|
var shape = obj.shape;
|
||||||
@@ -490,10 +490,10 @@
|
|||||||
this.tapStart = false;
|
this.tapStart = false;
|
||||||
},
|
},
|
||||||
_touchmove: function(evt) {
|
_touchmove: function(evt) {
|
||||||
this._setUserPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
var dd = Kinetic.DD;
|
var dd = Kinetic.DD;
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
var obj = this.getIntersection(this.getUserPosition());
|
var obj = this.getIntersection(this.getPointerPosition());
|
||||||
if(obj && obj.shape) {
|
if(obj && obj.shape) {
|
||||||
var shape = obj.shape;
|
var shape = obj.shape;
|
||||||
shape._handleEvent('touchmove', evt);
|
shape._handleEvent('touchmove', evt);
|
||||||
|
Reference in New Issue
Block a user