|
1 | | -## **文档完善中** |
| 1 | +## **GestureDetector** |
| 2 | +> 该组件可监听触摸事件,可包裹需要监听的组件后使用带有的触摸事件。 |
| 3 | +
|
| 4 | +### 构造函数 |
| 5 | +``` |
| 6 | +GestureDetector({ |
| 7 | + Key key, |
| 8 | + this.child, |
| 9 | + this.onTapDown, |
| 10 | + this.onTapUp, |
| 11 | + this.onTap, |
| 12 | + this.onTapCancel, |
| 13 | + this.onDoubleTap, |
| 14 | + this.onLongPress, |
| 15 | + this.onLongPressUp, |
| 16 | + this.onLongPressDragStart, |
| 17 | + this.onLongPressDragUpdate, |
| 18 | + this.onLongPressDragUp, |
| 19 | + this.onVerticalDragDown, |
| 20 | + this.onVerticalDragStart, |
| 21 | + this.onVerticalDragUpdate, |
| 22 | + this.onVerticalDragEnd, |
| 23 | + this.onVerticalDragCancel, |
| 24 | + this.onHorizontalDragDown, |
| 25 | + this.onHorizontalDragStart, |
| 26 | + this.onHorizontalDragUpdate, |
| 27 | + this.onHorizontalDragEnd, |
| 28 | + this.onHorizontalDragCancel, |
| 29 | + this.onForcePressStart, |
| 30 | + this.onForcePressPeak, |
| 31 | + this.onForcePressUpdate, |
| 32 | + this.onForcePressEnd, |
| 33 | + this.onPanDown, |
| 34 | + this.onPanStart, |
| 35 | + this.onPanUpdate, |
| 36 | + this.onPanEnd, |
| 37 | + this.onPanCancel, |
| 38 | + this.onScaleStart, |
| 39 | + this.onScaleUpdate, |
| 40 | + this.onScaleEnd, |
| 41 | + this.behavior, |
| 42 | + this.excludeFromSemantics = false, |
| 43 | + this.dragStartBehavior = DragStartBehavior.down, |
| 44 | +}) |
| 45 | +``` |
| 46 | + |
| 47 | +### 属性介绍 |
| 48 | +> 点击事件可用Tap属性,执行顺序如下罗列 |
| 49 | +- onTapDown: 触摸时触发 |
| 50 | +- onTapUp: 触摸离开时触发 |
| 51 | +- onTap: 点击后触发 |
| 52 | +- onTapCancel: 触发时取消 |
| 53 | +- onDoubleTap: 200毫秒内触摸时触发,但不触发onTap |
| 54 | +> 拖动事件可用Pan属性,执行顺序如下罗列,拖动时返回是手势位移数据 |
| 55 | +- onPanDown: |
| 56 | +- onPanStart: (DragStartDetails e) {} 返回相对屏幕位置 |
| 57 | +- onPanUpdate: (DragUpdateDetails e) {} 回调函数中返回是手势位移数据 |
| 58 | +- onPanEnd: (DragEndDetails e) {} 回调函数中返回Velocity,手势瞬时速度,可结合动画使用 |
| 59 | +- onPanCancel: 回调取消 |
| 60 | +> 以下也可执行拖动事件,使用后不会触发Tap/Pan事件,执行顺序如下罗列,拖动时返回相对整个屏幕距离数据 |
| 61 | +- onForcePressStart: (ForcePressDetails e) {} |
| 62 | +- onForcePressPeak: (ForcePressDetails e) {} |
| 63 | +- onForcePressUpdate: (ForcePressDetails e) {} |
| 64 | +- onForcePressEnd: (ForcePressDetails e) {} |
| 65 | +> 监听垂直或水平方向 |
| 66 | +- onVerticalDragDown |
| 67 | +- onVerticalDragStart |
| 68 | +- onVerticalDragUpdate |
| 69 | +- onVerticalDragEnd |
| 70 | +- onVerticalDragCancel |
| 71 | +- onHorizontalDragDown |
| 72 | +- onHorizontalDragStart |
| 73 | +- onHorizontalDragUpdate |
| 74 | +- onHorizontalDragEnd |
| 75 | +- onHorizontalDragCancel |
| 76 | +> 手势放大 |
| 77 | +- onScaleStart |
| 78 | +- onScaleUpdate |
| 79 | +- onScaleEnd |
| 80 | + |
0 commit comments