| Files | Last commit | Last update |
|---|---|---|
| 1 year ago | ||
| 1 month ago | ||
| 1 year ago | ||
| 1 year ago | ||
| 7 months ago | ||
| 8 months ago | ||
| 1 year ago | ||
| 1 year ago | ||
| 1 year ago |
Solution to Gesture Event Conflicts
Overview
This sample demonstrates how to resolve gesture conflicts when gesture events are bound to multiple nested components or multiple gestures are bound to the same component.
How to Use
- GesturesConflictScene1: The Scroll and List components are nested to achieve unified scrolling.
- GesturesConflictScene2: The tap and double-tap gestures are mutually exclusive. The tap gesture takes precedence, and the double-tap gesture is not triggered.
- GesturesConflictScene2A: The tap and double-tap gestures are executed concurrently, with both events triggered.
- GesturesConflictScene3: System gestures override custom gestures. Long-pressing the Image component enlarges it, while the custom long-press gesture fails to trigger.
- GesturesConflictScene3A: The custom gesture uses the priorityGesture property. Long-pressing the Image component causes no change to the component; instead, the custom long-press gesture is triggered and a toast prompt is displayed.
- GesturesConflictScene4: Gesture event transparent transmission. Swipe left or right on the red component of the layer to display a toast.
- GesturesConflictScene5: After Button1 is configured with the event monopolization property .monopolizeEvents(true), pressing Button1 with one finger and tapping Button2 with another finger will not trigger the tap event of Button2.
- GesturesConflictScene6: Long-pressing the red area does not trigger the drag effect.
- GesturesConflictScene7: The Scroll component is nested in another Scroll component to implement unified scrolling.
- WebScrollDemo: The Web component is nested within the Scroll component, and the Text component in the red area scrolls synchronously with the Web component.
Project Directory
├──entry/src/main/ets
│ ├──entryability
│ │ └──EntryAbility.ets // Entry ability
│ ├──entrybackupability
│ │ └──EntryBackupAbility.ets // Data backup and restoration
│ └──pages
│ ├──GesturesConflictScene1.ets // Nested scroll container gesture conflict
│ ├──GesturesConflictScene2.ets // Combined gesture with multiple same-type gestures (negative example)
│ ├──GesturesConflictScene2A.ets // Combined gesture with multiple same-type gestures (positive example)
│ ├──GesturesConflictScene3.ets // Conflict between system gestures and custom gestures (negative example)
│ ├──GesturesConflictScene3A.ets // Conflict between system gestures and custom gestures (positive example)
│ ├──GesturesConflictScene4.ets // Transparent transmission of gesture events
│ ├──GesturesConflictScene5.ets // Multi-touch gesture conflict
│ ├──GesturesConflictScene6.ets // Dynamic gesture response control
│ ├──GesturesConflictScene7.ets // Parent component managing child gestures
│ ├──Index.ets // App home page
│ └──WebScrollDemo.ets // Example of Web and Scroll component nesting
└──entry/src/main/resources // App resources
Required Permissions
- ohos.permission.INTERNET: allows an app to access the Internet.
Constraints
- This sample is only supported on Huawei phones running standard systems.
- The HarmonyOS version must be HarmonyOS 5.0.5 Release or later.
- The DevEco Studio version must be DevEco Studio 5.0.5 Release or later.
- The HarmonyOS SDK version must be HarmonyOS 5.0.5 Release SDK or later.