Repository navigation
Prevent pull-to-refresh for every touch of a multi-touch gesture - #228
Open
officialasishkumar wants to merge 1 commit into
Open
officialasishkumar wants to merge 1 commit into
officialasishkumar wants to merge 1 commit into
Conversation
The touch tracking behind data-native-prevent-pull-to-refresh only looked at the touch that triggered each event. A second finger landing outside a protected element overwrote the state with false, and lifting any finger cleared it, even while another finger was still on the protected element. The SwipeRefreshLayout could then intercept the remaining finger's drag, e.g. after a two finger pinch on a map, and trigger a refresh. Derive the state from all active touches instead. On every touchstart, touchend and touchcancel, report whether any remaining touch is on a scrollable or protected element, and report the end of the touch once no touches remain. Handling touchcancel also stops the state from staying set after a canceled touch. Fixes hotwired#206
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #206
The touch tracking behind
data-native-prevent-pull-to-refresh(added in #98) only looked at the touch that triggered each event:touchstartchecked only the new finger's target, so a second finger landing outside a protected element overwrote the state withfalse.touchendalways cleared the state, even when another finger was still on the protected element.After a two-finger pinch on a map, lifting one finger let
HotwireSwipeRefreshLayoutintercept the remaining finger's drag and trigger a refresh.turbo.jsnow derives the state from all active touches. On everytouchstart,touchendandtouchcancel, it reports whether any remaining touch is on a scrollable or protected element, using the existing ancestor walk unchanged. When no touches remain, it reports the end of the touch. Handlingtouchcancelalso stops the state from staying set after a canceled touch. Single-touch behavior is the same as before, and nothing changes on the native side apart from the doc comments on the twoSessioncallbacks.There's no JavaScript test setup in the repo, so I tested this by running
turbo.jsagainst a stubbed DOM with these touch sequences: