File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -161,11 +161,20 @@ extension CompactSlider {
161161 }
162162
163163 func updateLinearProgress( _ newValue: Double , isEnded: Bool ) {
164- let newValue = newValue. clampedOrRotated ( rotated: options. contains ( . loopValues) )
164+ var newValue = newValue. clampedOrRotated ( rotated: options. contains ( . loopValues) )
165165 let progressAndIndex = nearestProgress ( for: newValue)
166166
167167 guard let linearProgressStep = step? . linearProgressStep else {
168- if progress. update ( newValue, at: progressAndIndex. index) , ( newValue == 1 || newValue == 0 ) {
168+ let precision : Double = style. type. isCenter ? 250 : 500
169+ let isHalf = ( newValue * precision) . rounded ( ) / precision == 0.5
170+
171+ // Help to find the 0 value for the center type.
172+ if isHalf, style. type. isCenter {
173+ newValue = 0.5
174+ }
175+
176+ if progress. update ( newValue, at: progressAndIndex. index) ,
177+ ( newValue == 1 || isHalf || newValue == 0 ) {
169178 HapticFeedback . vibrate ( isEnabled: isHapticFeedbackEnabled)
170179 }
171180
You can’t perform that action at this time.
0 commit comments