File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -79,11 +79,22 @@ - (void)tapHandler:(UITapGestureRecognizer *)gesture {
7979static float discreteValue (RNCSlider *sender, float value) {
8080 // If step is set and less than or equal to difference between max and min values,
8181 // pick the closest discrete multiple of step to return.
82+
8283 if (sender.step > 0 && sender.step <= (sender.maximumValue - sender.minimumValue )) {
84+
85+ // Round up when increase, round down when decrease.
86+ double (^_round)(double ) = ^(double x) {
87+ if (sender.lastValue > value) {
88+ return floor (x);
89+ } else {
90+ return ceil (x);
91+ }
92+ };
93+
8394 return
8495 MAX (sender.minimumValue ,
8596 MIN (sender.maximumValue ,
86- sender.minimumValue + round ((value - sender.minimumValue ) / sender.step ) * sender.step
97+ sender.minimumValue + _round ((value - sender.minimumValue ) / sender.step ) * sender.step
8798 )
8899 );
89100 }
You can’t perform that action at this time.
0 commit comments