ionic-team / ionic-team/ionic-framework

bug: Ionic Gesture - mismatched gesture details in the last onMove handler and the onEnd handler.

未关闭
#29,892 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
triage
主要语言
TypeScript
星标
52.7k
派生
13.3k
平均合并
1 天 15 小时
30 天内合并 PR
51

描述

### Prerequisites

- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already report this problem, without success.

### Ionic Framework Version

v8.x

### Current Behavior

Thank you for creating such a wonderful framework!
---
One can pass event handlers `onMove` and `onEnd` to the config object of `createGesture()`. These handlers are called with the details, such as `deltaX` and `deltaY`. The `onMove` handler fires regularly while the `onEnd` is called when the user interaction ends(typically on mouse up or touch end). In common cases, everything works pretty good. But the details passed to the two handlers mismatch if the user moves too fast, which causes the last part of changes to be unhandled because `onEnd` doesn't do what `onMove` does.

```javascript
const g = createGesture({
direction: 'x',
el: touchArea,
onMove: ({ deltaX }) => {
// manipulate styles of some elements, or set some states ...
console.log("onMove:", deltaX)
},
onEnd: ({ deltaX }) => {
// finalize and do some update ...
console.log("onEnd:", deltaX)
},
});
```

Possible console output if user swipes fast enough:
```
onMove: 2
onMove: 6
onMove: 38
onMove: 110
onMove: 270
onMove: 532
onEnd: 1192
```

Sometimes this behavior confuses recruits like me. It would be better that the gesture package "flushes" a `onMove` before `onEnd`, although developers may simply call `onMove` inside `onEnd` themselves.

### Expected Behavior

`onMove` gets called exactly before `onEnd`

### Steps to Reproduce

See [Reproduction on stackbliz](https://stackblitz.com/edit/vitejs-vite-ged8wu?file=src%2FApp.jsx).
Swipe the page fast horizontally.

### Code Reproduction URL

https://stackblitz.com/edit/vitejs-vite-ged8wu?file=src%2FApp.jsx

### Ionic Info

Ionic:

Ionic CLI : 7.2.0 (C:\Users\...\AppData\Roaming\nvm\v20.11.0\node_modules\@ionic\cli)
Ionic Framework : @ionic/react 8.2.7

Utility:

cordova-res : 0.15.4
native-run : 2.0.1

System:

NodeJS : v20.11.0 (C:\Program Files\nodejs\node.exe)
npm : 10.2.4
OS : Windows 10

### Additional Information

_No response_

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。