From 35778617a9bfae1e499a6f0fe7e833eb3361dd71 Mon Sep 17 00:00:00 2001 From: luoying_ace Date: Tue, 27 Sep 2022 07:15:50 +0000 Subject: [PATCH] update zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md. Signed-off-by: luoying_ace --- .../ts-basic-gestures-swipegesture.md | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md index 52a4901dd3..c516e93274 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-swipegesture.md @@ -1,6 +1,6 @@ # SwipeGesture -用于触发滑动事件,滑动最小速度为100vp/s时识别成功。 +用于触发滑动事件,滑动速度大于100vp/s时可识别成功。 > **说明:** > @@ -24,8 +24,8 @@ SwipeGesture(value?: { fingers?: number; direction?: SwipeDirection; speed?: num | 名称 | 描述 | | -------- | -------- | | All | 所有方向。 | -| Horizontal | 水平方向。 | -| Vertical | 竖直方向。 | +| Horizontal | 水平方向,手指滑动方向与x轴夹角小于45度时触发。 | +| Vertical | 竖直方向,手指滑动方向与y轴夹角小于45度时触发。 | | None | 任何方向均不可触发。 | @@ -35,7 +35,6 @@ SwipeGesture(value?: { fingers?: number; direction?: SwipeDirection; speed?: num | -------- | -------- | | onAction(event:(event?: [GestureEvent](ts-gesture-settings.md#gestureevent对象说明)) => void) | 滑动手势识别成功回调。 | -![zh-cn_image_0000001231374559](figures/zh-cn_image_0000001231374661.png) ## 示例 ```ts @@ -43,25 +42,29 @@ SwipeGesture(value?: { fingers?: number; direction?: SwipeDirection; speed?: num @Entry @Component struct SwipeGestureExample { - @State rotateAngle : number = 0 - @State speed : number = 1 + @State rotateAngle: number = 0; + @State speed: number = 1; build() { Column() { - Text("SwipGesture speed : " + this.speed) - Text("SwipGesture angle : " + this.rotateAngle) - } - .position({x: 80, y: 200}) - .border({width:2}) - .width(260).height(260) - .rotate({x: 0, y: 0, z: 1, angle: this.rotateAngle}) - .gesture( - SwipeGesture({fingers: 1, direction: SwipeDirection.Vertical}) + Column() { + Text("SwipeGesture speed\n" + this.speed) + Text("SwipeGesture angle\n" + this.rotateAngle) + } + .border({ width: 3 }) + .width(300) + .height(200) + .margin(100) + .rotate({ angle: this.rotateAngle }) + // 单指竖直方向滑动时触发该事件 + .gesture( + SwipeGesture({ direction: SwipeDirection.Vertical }) .onAction((event: GestureEvent) => { - this.speed = event.speed - this.rotateAngle = event.angle - }) - ) + this.speed = event.speed; + this.rotateAngle = event.angle; + }) + ) + }.width('100%') } } ``` -- GitLab