yonat / MultiSlider

UISlider clone with multiple thumbs and values, range highlight, optional snap intervals, optional value labels, either vertical or horizontal.
MIT License
494 stars 113 forks source link

run func at and of drag in SwiftUI #101

Closed ahartman closed 9 months ago

ahartman commented 9 months ago

I see I tagged this as a bug but that is not my intention as I had it working. Sorry about that.

I have a question: how do I react to endOfDrag in SwiftUI? .valueChanged and .touchUpInside give an error :'Value of type 'MultiValueSlider' has no member 'touchUpInside'

Regards, ahartman, Belgium

yonat commented 9 months ago

Hi @ahartman , please say more about what you are trying to achieve. What will happen on the end of the drag? What is the difference between it and setting slider.isContinuous = false ?

ahartman commented 9 months ago

Dear Yonat,

Thank you for your quick reaction. In your README.md two events are mentioned: .valueChanged and .touchUpInside

I would like to react to .touchUpInside to run business logic with the new values once the user ends dragging the slider.

Kind regards, ahartman, Belgium

yonat commented 9 months ago

Try setting isContinuous to false (in MultiValueSlider init) and then you can use .onChange().

ahartman commented 9 months ago

Dear Yonat,

Thank you, that fixed the issue.

What is the difference between .isContinuous = false and snapStepSize? snapStepSize makes the slider discontinuous as well in my opinion?

You might make your example fully SwiftUI and show the .onChange. I would think nobody wants a slider for nothing, so it is essential to note endOfChange and be able to react to newly set values.

Tjaks again,

ahartman, belgium

Op 27 jan 2024, om 18:15 heeft Yonat Sharon @.***> het volgende geschreven:

Try setting isContinuous to false (in MultiValueSlider init) and then you can use .onChange().

— Reply to this email directly, view it on GitHub https://github.com/yonat/MultiSlider/issues/101#issuecomment-1913264136, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFIBPFMWLCE6A7SYOHK5NTYQUYZTAVCNFSM6AAAAABCIVEBDSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJTGI3DIMJTGY. You are receiving this because you were mentioned.

yonat commented 9 months ago

isContinuous is the same as for the standard UISlider -- see UISlider.isContinuous documentation.

onChange is standard in SwiftUI -- see SwiftUI onChange documentation.