Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to swipe/drag between values with new iOS modal presentation style #148

Open
benpackard opened this issue Sep 30, 2019 · 8 comments

Comments

@benpackard
Copy link
Contributor

benpackard commented Sep 30, 2019

iOS 13 introduced a new default modal presentation style that allows the user to dismiss with a downwards gesture. Unfortunately this interferes with dragging from one star rating to another in Cosmos.

To reproduce:

  1. Add a CosmosView to a view controller and present it modally on iOS 13.
  2. Attempt to drag your finger from one star to the next

Expected: the star rating changes as the user drags her finger

Actual: the star rating does not change

A few observations:

  • I am using the latest version of Cosmos and iOS 13.1.1
  • The CosmosView works as expected if the view controller's modalPresentationStyle is changed to .fullScreen
  • On close inspection, a drag gesture does allow for value changes of half-step increments, but as soon as the gesture leaves one star for the next star, the gesture is dropped.
  • Setting the parent scroll view's canCancelContentTouches to false does not seem to help.
  • Setting passTouchesToSuperview to false does not help.
@benpackard
Copy link
Contributor Author

benpackard commented Sep 30, 2019

Some screen recordings:

Working (full screen).

Not working (partial modal).

@benpackard
Copy link
Contributor Author

benpackard commented Sep 30, 2019

I've confirmed that didFinishTouchingCosmos fires as the gesture leaves the edge of the star that initiated it. Without knowing to much about how gestures work, perhaps Cosmos doesn't expect to be added on top of another gesture and the new modal 'dismiss' gesture is picking up the drag as soon as it hits the gap between stars?

This might be helpful: https://stackoverflow.com/questions/56718552/disable-gesture-to-pull-down-form-page-sheet-modal-presentation

@benpackard
Copy link
Contributor Author

Here is the workaround I am using now based on the stackoverflow answer above. It's very naive but it works. Let me know if this would make for a good PR. There are probably some other consequences I am not considering here.

private class FixedCosmosView: CosmosView {
	override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
		return !(gestureRecognizer is UIPanGestureRecognizer)
	}
}

@evgenyneu
Copy link
Owner

evgenyneu commented Sep 30, 2019

Hi @benpackard. Holy! This is an amazing bug report, thank you very much. And thanks for finding a workaround (gestureRecognizerShouldBegin). It works very well inside a modal screen, same way it works usually.

However, I noticed that this workaround changes things a bit when Cosmos view is inside a table view. In order to see that, click "Performance button" in the top right corner of the Demo app, as shown on Fig. 1. It will show a table view with many rating controls.

Now, without your workaround, one can scroll through the table view by touching anywhere in the table view, including a cosmos view (see Fig. 2). After I included your workaround, however, I could not scroll the table when my scroll gesture started within a Cosmos view.

What do you think we should do here? If we add this workaround as it is, it might introduce these scrolling issues to existing apps and people will be angry. Maybe we can add a flag in Cosmos settings, disablePanGenstures, which is false by default? Also we could add a note to Readme to do

cosmosView.settings.disablePanGenstures = true

in order to make Cosmos work in the modal screens?

cosmos_table_view

Figure 1: Opening a table view in a demo app


cosmos_table_view_scrolling

Figure 2: Scrolling table view by first touching the Cosmos rating view.

@benpackard
Copy link
Contributor Author

@evgenyneu A flag sounds like the right path forward. I do wonder though what happens for a table view in a modal, where the user might need both behaviors. If I get some time this evening I'll test that scenario out.

@evgenyneu
Copy link
Owner

@benpackard, thanks. Feel free to submit a pull request, if you want.

@benpackard
Copy link
Contributor Author

Submitted a pull request, hope I didn't miss anything!

@gunnarsson
Copy link

I ran into this problem and solved using the flag mentioned above. Thanks!

My preferred fix (without knowing much about the implementation) would be that pan events that are initially mostly vertical are allowed and lets the user scroll the parent view, but that mostly horizontal pan events are captured and used to adjust the rating. Would this be possible? This behaviour is common throughout iOS, one example is the Mail app. If you begin swiping a mail horizontally it's not possible to scroll the list until you've ended the gesture, and the other way around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants