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

Changes #70

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Changes #70

wants to merge 11 commits into from

Conversation

jacobp100
Copy link
Contributor

@jacobp100 jacobp100 commented Aug 1, 2023

Sets the minimum distance to 0, so fine adjustments are possible

Makes the selectUpper/selectLower gestures simultaneous so they won't delay the dragging. There might need to be some logic here to revert to the previous value if they tapped but slightly moved their thumb

Refactors some (Horizontal{Value,Range}Sliders) to use @GestureState - which properly tracks when gestures are cancelled (which onEnd does not do). The others need updating, but I'm lazy

Fixes simultaneous gestures when using interactive track, and putting a finger on the thumb and track

Adds precisionScrubbing which lets you move your finger down to slow down the scrubbing speed:-

enum ScrubbingSpeed: Float {
  case normal = 1, slow = 2
}

struct Example: View {
  var body: some View {
    yourSlider.precisionScrubbing { offset -> ScrubbingSpeed in
      if (abs(offset) > 200) {
        return .slow
      } else {
        return .normal
      }
    } onChange: { newSpeed in
      print(newSpeed) // Maybe add to the UI, play some haptics or something
    }
  }
}

It may look like extra ceremony declaring an enum for scrubbing speeds - and you may think you could just return a float. However - it's absolutely critical that there are a limited number of values returned for the scrubbing speed. When going from a slower to faster scrubbing speed (e.g. 8x slow down to 4x), you have to 'undo' the 8x adjustments, and apply them to the 4x. This is what happens in the iOS video player (although they managed to animate this change). This basically means storing every speed and the corresponding offset accumulations in a dictionary, and if the user could freely return any float, and they may be tempted to use linear interpolation for the speed, which would make the dictionary huge

@jacobp100 jacobp100 changed the title Improve responsiveness of slider thumbs Changes Aug 9, 2023
@armoona
Copy link

armoona commented Feb 24, 2024

Thank you for sharing the bug fix for the drag delay. I hope it gets merged one day.

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

Successfully merging this pull request may close these issues.

2 participants