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

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 String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

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.