Post

Replies

Boosts

Views

Activity

Reply to Simultaneous Drag and Magnification Gestures
The problems lies way beyond ‘simultaneous or exclusive’ and is in my opinion a serious bug with a lot of side effects and inconsistencies. You only need one single view with one single drag gesture attached to it! Set ‘minimumDistance: 0’ so the gesture gets recognized right away (like at touchBegan/touchDown of a tap gesture) and let the .onChange(), .onEnded() and .updating() closures print something to the console for checking when they fire. Now start dragging (first gesture) and while doing so accidentally touch/tap/press the screen with another finger. The ‘new’ (second) gesture does NOT get reported to you by the system! No callback gets fired… HOWEVER, your original first gesture gets killed, which means no more updates, changes and - BIG BUMMER - no .onEnded callback!!! And as there is no .onCancel callback like in UIKit, this behavior leaves you with dangling gestures and every state machine that you tried to establish with pairs of ‘started-ended‘ gets screwed up big time. When you then place yet another ‘new‘ (third) gesture, a fresh drag gesture gets spun up (reporting all callbacks like it’s supposed to) but being totally ignorant of the two former gestures, regardless of whether you lifted the finger of your first and second gesture or one/both fingers are still on the screen !!! And that is the reason why drag gestures (a one finger gesture) don’t work simultaneously with 2 finger gestures like magnification or rotation. Because the second finger that touches the screen kills the drag gesture but magnification and rotation start and keep on firing… Attach more drag gestures to the same view, they all keep firing simultaneously without any problem whatsoever. Any combination and number of rotations/magnifications - same correct behavior… But put a drag gesture in the mix and the whole thing brakes! That is for sure not as it’s supposed to work…
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to Simultaneous Drag and Magnification Gestures
The problems lies way beyond ‘simultaneous or exclusive’ and is in my opinion a serious bug with a lot of side effects and inconsistencies. You only need one single view with one single drag gesture attached to it! Set ‘minimumDistance: 0’ so the gesture gets recognized right away (like at touchBegan/touchDown of a tap gesture) and let the .onChange(), .onEnded() and .updating() closures print something to the console for checking when they fire. Now start dragging (first gesture) and while doing so accidentally touch/tap/press the screen with another finger. The ‘new’ (second) gesture does NOT get reported to you by the system! No callback gets fired… HOWEVER, your original first gesture gets killed, which means no more updates, changes and - BIG BUMMER - no .onEnded callback!!! And as there is no .onCancel callback like in UIKit, this behavior leaves you with dangling gestures and every state machine that you tried to establish with pairs of ‘started-ended‘ gets screwed up big time. When you then place yet another ‘new‘ (third) gesture, a fresh drag gesture gets spun up (reporting all callbacks like it’s supposed to) but being totally ignorant of the two former gestures, regardless of whether you lifted the finger of your first and second gesture or one/both fingers are still on the screen !!! And that is the reason why drag gestures (a one finger gesture) don’t work simultaneously with 2 finger gestures like magnification or rotation. Because the second finger that touches the screen kills the drag gesture but magnification and rotation start and keep on firing… Attach more drag gestures to the same view, they all keep firing simultaneously without any problem whatsoever. Any combination and number of rotations/magnifications - same correct behavior… But put a drag gesture in the mix and the whole thing brakes! That is for sure not as it’s supposed to work…
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22