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

Setting the step property of a slider slows it WAAAYYYY down.

Forums > SwiftUI

I have an app that simulates particle life (similar to webgl-particle-life.netlify.app/)

I use 16 sliders to adjust the various parameters. I set the sliders up like this:

Slider(value: $particleModel.gravs[3][2], in: -1.0...1.0, step: 0.01)

I also have a function that randomizes the various parameters tied to a button. This function took 1-2 seconds to return after the button click. I finally traced it down to the "step" setting in the sliders. At first, I set them 0.1 and got noticeable speed up. When I deleted them altogether I got nice snappy performance.

I have not seen this mentioned any where, am I doing something wrong setting them up? Is this expected?

   

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.

Click to save your free spot now

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

Reply to this topic…

You need to create an account or log in to reply.

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.