diff --git a/package.json b/package.json index b230653d..49451aa5 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/Stage.js b/src/Stage.js index 4793686b..ea5a3d66 100644 --- a/src/Stage.js +++ b/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 }; diff --git a/src/shapes/Text.js b/src/shapes/Text.js index 02b58f92..bf737843 100644 --- a/src/shapes/Text.js +++ b/src/shapes/Text.js @@ -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 diff --git a/test/functional/TouchEvents-test.js b/test/functional/TouchEvents-test.js index 49dfaf1e..4ce8490d 100644 --- a/test/functional/TouchEvents-test.js +++ b/test/functional/TouchEvents-test.js @@ -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() { } });