mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
fixed #673
This commit is contained in:
parent
7468c2862a
commit
6bd0992dd8
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "KineticJS",
|
||||
"version": "4.7.3",
|
||||
"version": "4.7.4",
|
||||
"devDependencies": {
|
||||
"grunt-contrib-jshint": "~0.5.4",
|
||||
"grunt-contrib-nodeunit": "~0.1.2",
|
||||
|
29
src/Stage.js
29
src/Stage.js
@ -557,18 +557,21 @@
|
||||
contentPosition = this._getContentPosition(),
|
||||
offsetX = evt.offsetX,
|
||||
clientX = evt.clientX,
|
||||
x = 0,
|
||||
y = 0,
|
||||
x = null,
|
||||
y = null,
|
||||
touch;
|
||||
|
||||
// touch events
|
||||
if(evt.touches !== undefined && evt.touches.length === 1) {
|
||||
// one finger
|
||||
touch = evt.touches[0];
|
||||
if(evt.touches !== undefined) {
|
||||
// currently, only handle one finger
|
||||
if (evt.touches.length === 1) {
|
||||
|
||||
// get the information for finger #1
|
||||
x = touch.clientX - contentPosition.left;
|
||||
y = touch.clientY - contentPosition.top;
|
||||
touch = evt.touches[0];
|
||||
|
||||
// get the information for finger #1
|
||||
x = touch.clientX - contentPosition.left;
|
||||
y = touch.clientY - contentPosition.top;
|
||||
}
|
||||
}
|
||||
// mouse events
|
||||
else {
|
||||
@ -592,10 +595,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
this.pointerPos = {
|
||||
x: x,
|
||||
y: y
|
||||
};
|
||||
if (x !== null && y !== null) {
|
||||
this.pointerPos = {
|
||||
x: x,
|
||||
y: y
|
||||
};
|
||||
}
|
||||
},
|
||||
_getContentPosition: function() {
|
||||
var rect = this.content.getBoundingClientRect ? this.content.getBoundingClientRect() : { top: 0, left: 0 };
|
||||
|
@ -32,7 +32,7 @@
|
||||
* @memberof Kinetic
|
||||
* @augments Kinetic.Shape
|
||||
* @param {Object} config
|
||||
* @param {String} [config.fontFamily] default is Calibri
|
||||
* @param {String} [config.fontFamily] default is Arial
|
||||
* @param {Number} [config.fontSize] in pixels. Default is 12
|
||||
* @param {String} [config.fontStyle] can be normal, bold, or italic. Default is normal
|
||||
* @param {String} config.text
|
||||
|
@ -58,13 +58,14 @@ suite('TouchEvents', function() {
|
||||
});
|
||||
|
||||
stage._touchstart({
|
||||
clientX: 100,
|
||||
clientY: 100 + top
|
||||
touches: [{
|
||||
clientX: 100,
|
||||
clientY: 100 + top
|
||||
}]
|
||||
});
|
||||
|
||||
stage._touchend({
|
||||
clientX: 100,
|
||||
clientY: 100 + top
|
||||
touches: []
|
||||
});
|
||||
|
||||
assert.equal(circleTouchstart, 1, 1);
|
||||
@ -74,12 +75,13 @@ suite('TouchEvents', function() {
|
||||
assert.equal(stageContentDbltap, 0, 5);
|
||||
|
||||
stage._touchstart({
|
||||
clientX: 1,
|
||||
clientY: 1 + top
|
||||
touches: [{
|
||||
clientX: 1,
|
||||
clientY: 1 + top
|
||||
}]
|
||||
});
|
||||
stage._touchend({
|
||||
clientX: 1,
|
||||
clientY: 1 + top
|
||||
touches: []
|
||||
});
|
||||
|
||||
assert.equal(stageContentTouchstart, 2, 6);
|
||||
@ -117,10 +119,12 @@ suite('TouchEvents', function() {
|
||||
circle.on('touchstart', function() {
|
||||
touchstart = true;
|
||||
//log('touchstart');
|
||||
//alert('touchstart')
|
||||
});
|
||||
|
||||
circle.on('touchend', function() {
|
||||
touchend = true;
|
||||
//alert('touchend')
|
||||
//log('touchend');
|
||||
});
|
||||
|
||||
@ -149,8 +153,10 @@ suite('TouchEvents', function() {
|
||||
|
||||
// touchstart circle
|
||||
stage._touchstart({
|
||||
clientX: 289,
|
||||
clientY: 100 + top,
|
||||
touches: [{
|
||||
clientX: 289,
|
||||
clientY: 100 + top,
|
||||
}],
|
||||
preventDefault: function() {
|
||||
}
|
||||
});
|
||||
@ -163,8 +169,7 @@ suite('TouchEvents', function() {
|
||||
|
||||
// touchend circle
|
||||
stage._touchend({
|
||||
clientX: 289,
|
||||
clientY: 100 + top,
|
||||
touches: [],
|
||||
preventDefault: function() {
|
||||
}
|
||||
});
|
||||
@ -180,8 +185,10 @@ suite('TouchEvents', function() {
|
||||
|
||||
// touchstart circle
|
||||
stage._touchstart({
|
||||
clientX: 289,
|
||||
clientY: 100 + top,
|
||||
touches: [{
|
||||
clientX: 289,
|
||||
clientY: 100 + top,
|
||||
}],
|
||||
preventDefault: function() {
|
||||
}
|
||||
});
|
||||
@ -194,8 +201,7 @@ suite('TouchEvents', function() {
|
||||
|
||||
// touchend circle to triger dbltap
|
||||
stage._touchend({
|
||||
clientX: 289,
|
||||
clientY: 100 + top,
|
||||
touches: [],
|
||||
preventDefault: function() {
|
||||
}
|
||||
});
|
||||
@ -211,8 +217,10 @@ suite('TouchEvents', function() {
|
||||
|
||||
// touchmove circle
|
||||
stage._touchmove({
|
||||
clientX: 290,
|
||||
clientY: 100 + top,
|
||||
touches: [{
|
||||
clientX: 290,
|
||||
clientY: 100 + top,
|
||||
}],
|
||||
preventDefault: function() {
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user