UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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 Superwall

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

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.