2011年7月28日 星期四

HTML5 in mobile

紀錄一下有關HTML5 在行動平台上的滑鼠監聽事件
web mobile
onmousemove touchmove
onmousedown touchstart
onmouseup touchend

/**************************************************************************
程式碼
/**************************************************************************
window.addEventListener("touchmove", this, false);
this.stage.onmousemove = stageMouseEvent;
}
}
Stage.prototype.handleEvent = function (event)
{
switch(event.type)
{
case "touchstart" :
this.onTouchStart(event);
break;
case "touchmove" :
this.onTouchMove(event);
break;
case "touchend" :
this.onTouchEnd(event);
break;
}
}
Stage.prototype.onTouchMove = function(e)
{
e.preventDefault();
/* Stop tracking if targetTouches contains multiple touches (this means that a gesture event has occurred)*/
if (e.targetTouches.length != 1)
{
return false;
}
/* trace x,y */
mouseXY("Stage:" + e.targetTouches[0].clientX + ',' + e.targetTouches[0].clientY);
return false;
}

沒有留言:

張貼留言