TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

DragGesture blocks touching a Slider

Forums > SwiftUI

Let's take a look at this code:

@State private var progress: TimeInterval = 0    

Slider(value: $progress, in: 0 ... Double(100), onEditingChanged: { didChange in
    seekToProgress(p: progress)
}).simultaneousGesture(
    DragGesture(minimumDistance: 0)
        .onChanged { gesture in
            print("gesture onChanged")
        }
        .onEnded { gesture in
            print("gesture onEnded")
        }
)

I want to track touch down and end events on the slider, but this blocks the actual Slider from being touched. In another words, DragGesture seems to consuming touches despite using simultaneousGesture. I've also tried adding GestureMaska.all but it didn't work either. How can I fix this? I need to keep track of touch down/up, because this slider is used to seek an audio track, but also audio tracks updates the slider. However it shoudn't do it, when user is touching the slider.

3      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.