|
@@ -74,6 +74,8 @@ export class SCanvasView extends SObject {
|
|
|
|
|
|
/** 手执状态 */
|
|
|
private _touchState = STouchState.None;
|
|
|
+ /** 手指拖动点 */
|
|
|
+ private _touchPoint = new SPoint();
|
|
|
/** 未缩放时二指间距离 */
|
|
|
private _beforeLength = 0;
|
|
|
/** 缩放后二指间距离 */
|
|
@@ -297,21 +299,44 @@ export class SCanvasView extends SObject {
|
|
|
*
|
|
|
* @param event 事件参数
|
|
|
*/
|
|
|
- protected onTouchStart(event: TouchEvent): void {} // Function onTouchStart()
|
|
|
+ protected onTouchStart(event: TouchEvent): void {
|
|
|
+ let touches = event.touches;
|
|
|
+ if (touches.length == 1) {
|
|
|
+ this._touchPoint.x = event.touches[0].clientX;
|
|
|
+ this._touchPoint.y = event.touches[0].clientY;
|
|
|
+ }
|
|
|
+ if (touches.length == 2) {
|
|
|
+ this._touchState = STouchState.Zoom;
|
|
|
+ this._beforeLength = this.getDistance(event);
|
|
|
+ }
|
|
|
+ } // Function onTouchStart()
|
|
|
|
|
|
/**
|
|
|
* 触摸移动事件
|
|
|
*
|
|
|
* @param event 事件参数
|
|
|
*/
|
|
|
- protected onTouchMove(event: TouchEvent): void {} // Function onTouchMove()
|
|
|
+ protected onTouchMove(event: TouchEvent): void {
|
|
|
+ let touches = event.touches;
|
|
|
+ if (touches.length == 1) {
|
|
|
+ this.origin.x += event.touches[0].clientX - this._touchPoint.x;
|
|
|
+ this.origin.y += event.touches[0].clientY - this._touchPoint.y;
|
|
|
+ this._touchPoint.x = event.touches[0].clientX;
|
|
|
+ this._touchPoint.y = event.touches[0].clientY;
|
|
|
+ }
|
|
|
+ if (touches.length == 2) {
|
|
|
+ this.viewZoom(event);
|
|
|
+ }
|
|
|
+ } // Function onTouchMove()
|
|
|
|
|
|
/**
|
|
|
* 结束触摸事件
|
|
|
*
|
|
|
* @param event 事件参数
|
|
|
*/
|
|
|
- protected onTouchEnd(event: TouchEvent): void {} // Function onTouchEnd()
|
|
|
+ protected onTouchEnd(event: TouchEvent): void {
|
|
|
+ this._touchState = STouchState.None;
|
|
|
+ } // Function onTouchEnd()
|
|
|
|
|
|
/**
|
|
|
* View大小变更事件
|