Touch interaction updates
Fixed null error that was occuring on touchend in interaction manager. Windows 8 phone css added to view to prevent default zoom
This commit is contained in:
parent
a1faefe5c7
commit
c1c4d75a3d
12 changed files with 313 additions and 112 deletions
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2012, Mat Groves
|
||||
* http://goodboydigital.com/
|
||||
*
|
||||
* Compiled: 2013-04-15
|
||||
* Compiled: 2013-04-16
|
||||
*
|
||||
* Pixi.JS is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -814,16 +814,32 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
this.target = target;
|
||||
target.view.addEventListener('mousemove', this.onMouseMove.bind(this), true);
|
||||
target.view.addEventListener('mousedown', this.onMouseDown.bind(this), true);
|
||||
document.body.addEventListener('mouseup', this.onMouseUp.bind(this), true);
|
||||
target.view.addEventListener('mouseout', this.onMouseUp.bind(this), true);
|
||||
if (window.navigator.msPointerEnabled)
|
||||
{
|
||||
// time to remove some of that zoom in ja..
|
||||
target.view.style["-ms-content-zooming"] = "none";
|
||||
target.view.style["-ms-touch-action"] = "none"
|
||||
|
||||
// DO some window specific touch!
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
|
||||
this.target = target;
|
||||
target.view.addEventListener('mousemove', this.onMouseMove.bind(this), true);
|
||||
target.view.addEventListener('mousedown', this.onMouseDown.bind(this), true);
|
||||
document.body.addEventListener('mouseup', this.onMouseUp.bind(this), true);
|
||||
target.view.addEventListener('mouseout', this.onMouseUp.bind(this), true);
|
||||
|
||||
// aint no multi touch just yet!
|
||||
target.view.addEventListener("touchstart", this.onTouchStart.bind(this), true);
|
||||
target.view.addEventListener("touchend", this.onTouchEnd.bind(this), true);
|
||||
target.view.addEventListener("touchmove", this.onTouchMove.bind(this), true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// aint no multi touch just yet!
|
||||
target.view.addEventListener("touchstart", this.onTouchStart.bind(this), true);
|
||||
target.view.addEventListener("touchend", this.onTouchEnd.bind(this), true);
|
||||
target.view.addEventListener("touchmove", this.onTouchMove.bind(this), true);
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.update = function()
|
||||
|
@ -1132,6 +1148,7 @@ PIXI.InteractionManager.prototype.onTouchStart = function(event)
|
|||
//call the function!
|
||||
if(item.touchstart)item.touchstart(touchData);
|
||||
item.__isDown = true;
|
||||
item.__touchData = touchData;
|
||||
|
||||
if(!item.interactiveChildren)break;
|
||||
}
|
||||
|
@ -1145,11 +1162,13 @@ PIXI.InteractionManager.prototype.onTouchEnd = function(event)
|
|||
{
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
var rect = this.target.view.getBoundingClientRect();
|
||||
var changedTouches = event.changedTouches;
|
||||
|
||||
for (var i=0; i < changedTouches.length; i++)
|
||||
{
|
||||
|
||||
var touchEvent = changedTouches[i];
|
||||
var touchData = this.touchs[touchEvent.identifier];
|
||||
var up = false;
|
||||
|
@ -1160,6 +1179,7 @@ PIXI.InteractionManager.prototype.onTouchEnd = function(event)
|
|||
for (var j = 0; j < length; j++)
|
||||
{
|
||||
var item = this.interactiveItems[j];
|
||||
var itemTouchData = item.__touchData; // <-- Here!
|
||||
item.__hit = this.hitTest(item, touchData);
|
||||
|
||||
if(itemTouchData == touchData)
|
||||
|
@ -1191,7 +1211,7 @@ PIXI.InteractionManager.prototype.onTouchEnd = function(event)
|
|||
item.__isDown = false;
|
||||
}
|
||||
|
||||
item.__touchIdentifier = null;
|
||||
item.__touchData = null;
|
||||
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue