IOS Android Ipad 多点触摸通用js 库(3)
来源:未知 责任编辑:责任编辑 发表时间:2014-02-02 17:44 点击:次
p>break;
p>case "touchmove":
p>var str = "";
p>event.preventDefault();
p>var currentTime = event.timeStamp;
p>if (startTime !== 0 && currentTime - startTime > minTime) {
p>EX = event.changedTouches[0].clientX;
p>EY = event.changedTouches[0].clientY;
p>try {
p>EX1 = event.touches[1].clientX;
p>EY1 = event.touches[1].clientY;
p>}
p>catch (err) { }
p>CallBackTouchEnd();
p>}
p>break;
p>}
p>}
p>
p>function CallBackTouchEnd() {
p>startTime = 0;
p>startX = 0;
p>var mTouchType;
p>var mValue;
p>
p>if ((SX1 !== 0) && (SY1 !== 0) && (EX1 !== 0) && (EY1 !== 0)) {
p>mTouchType = TouchType.Zoom;
p>mValue = Scaling(SX, SY, EX, EY, SX1, SY1, EX1, EY1);
p>}
p>else {
p>var DiffY = Math.abs(EY - SY);
p>var DiffX = Math.abs(EX - SX);
p>if (DiffY >= DiffX) {
p>mValue = DiffY;
p>if (EY >= SY)
p>mTouchType = TouchType.Down;
p>else
p>mTouchType = TouchType.Up;
p>}
p>else {
p>mValue = DiffX;
p>if (EX >= SX)
p>mTouchType = TouchType.Right;
p>else
p>mTouchType = TouchType.Left;
p>}
p>}
p>
p>if (this.isLog) {
p>output.innerHTML += "开始:" + SX + ":" + SY + "\n";
p>output.innerHTML += "结束:" + EX + ":" + EY + "\n";
p>switch(mTouchType)
p>{
p>case TouchType.Up:
p>output.innerHTML += "向上移动了:" + mValue + "\n";
p>break;
p>case TouchType.Down:
p>output.innerHTML += "向下移动了:" + mValue + "\n";
p>break;
p>case TouchType.Left:
p>output.innerHTML += "向左移动了:" + mValue + "\n";
p>break;
p>case TouchType.Right:
p>output.innerHTML += "向右移动了:" + mValue + "\n";
p>break;
p>case TouchType.Zoom:
p>output.innerHTML += "开始1:" + SX1 + ":" + SY1 + "\n";
p>output.innerHTML += "结束1:" + EX1 + ":" + EY1 + "\n";
p>output.innerHTML += "缩放比例是:" + mValue + "\n";
p>break;
p>default:
p>break;
p>}
p>}
p>
p>CallBack(SX, SY, EX, EY, SX1, SY1, EX1, EY1, mTouchType, mValue);
p>SX = 0; SY = 0; EX = 0; EY = 0;
p>SX1 = 0; SY1 = 0; EX1 = 0; EY1 = 0;
p>}
p>
p>document.getElementById(TouchObjId).addEventListener("touchstart", handleTouchEvent, false);
p>document.getElementById(TouchObjId).addEventListener("touchmove", handleTouchEvent, false);
p>document.getElementById(TouchObjId).addEventListener("touchend", handleTouchEvent, false);
p>}
p>
相关新闻>>
- 发表评论
-
- 最新评论 更多>>