-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
maxDistance and minDistance #4
Conversation
- move leftHandSelected and rightHandSelected to TTRangeSlider.m (private to public)
- add minDistance and maxDistance
- add minDistance and maxDistance to keep the distance between left handle and right handle
- move minLabel and maxLabel, maybe someone need to modify label text by programmatically
@@ -268,6 +263,64 @@ - (void)refresh { | |||
if (self.delegate){ | |||
[self.delegate rangeSlider:self didChangeSelectedMinimumValue:self.selectedMinimum andMaximumValue:self.selectedMaximum]; | |||
} | |||
|
|||
if (self.minDistance != -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! Thanks a lot for helping out and submitting the PR, but I think I can't merge it at the moment.
There's a lot of duplication in these two blocks, and also I feel like this way of ensuring the min or max difference properties are kept doesn't fit in with the method. If you check out the lines at the start of the refresh method, this is how we make sure the slider doesn't go off the end of the scale, by accessing the property values directly we make sure that the refresh method isn't called again.
Also we make sure the changes are made before the delegate is updated. I think with how this PR is at the moment, any delegates will be updated with the wrong values first, and then the whole refresh method will be called again. I'm also not completely sure I understand the whole if((self.minDistance - diff) < 0.001)
offset thing?
If this could maybe be tidied up though to be in the same pattern as the minValue
and maxValue
stuff at the start of the refresh method, and remove as much duplication as possible, I would be happy to accept and merge it :-)
thanks again!
Hey! Thank a lot for your PR. I do genuinely really appreciate PRs and people helping out! I've added a comment with some thoughts. I think the min and max value properties is a great idea. However I'm not too sure about making the other properties public though. I think it would be better if people need to set fonts or selected values etc. to expose methods to do this work rather than the actual properties themselves? |
ok, thank you for your review. I will modify code and pull request again : ) |
- add property minLabelText, maxLabelText, minLabelFont, maxLabelFont - add property leftHandleFrame, rightHandleFrame to get the handle position
- add property leftHandleFrame, rightHandleFrame to get the handle position - bug fix - rearrange code in refresh method
Hi, I did some change about property and refresh method. |
Hey! Thanks for looking at this again. Can I suggest that maybe we ignore the extra properties for now? Theres a few potential issues I think I can spot by looking at the code (although admittedly I haven't run it yet) regarding for example
Sorry if I'm being overly critical but I want to make sure things are right before doing any merges that could break or complicate things. Thats why I think it might be best to leave those out for now, and concentrate on just the max and min distance properties? Then we could add the other ones later. Also there's a few times where I think your IDE has added spaces on blank lines (like 154, 189 etc.) Would you mind taking them out so it cleans up the diff? Regarding the code for min and max distance, what you wrote is pretty much right really. I just thought you could move the diff calculation out of the conditionals, and I'm not sure you need the offset stuff? Although correct me if I'm wrong! Something like this (which still has some duplication but its definitely a balance for readability :D) : float diff = self.selectedMaximum - self.selectedMinimum;
if (minDiff > 0 && diff < minDiff){
if (self.leftHandleSelected){
_selectedMinimum = self.selectedMaximum - minDiff;
} else {
_selectedMaximum = self.selectedMinimum + minDiff;
}
} else if (maxDiff > 0 && diff > maxDiff){
if (self.leftHandleSelected){
_selectedMinimum = self.selectedMaximum - maxDiff;
} else {
_selectedMaximum = self.selectedMinimum + maxDiff;
}
} Sorry again for being picky and thanks for your work! |
Hi, It's ok. Thank you for your review. And I worry that waste your time to review. :-) If drag the right handle and over the maxDistance. As you say, focus on the minDistance and maxDistance. |
Ah, I see. Yeah I didn't think about moving the other slider to maintain the distance. That's a pretty good idea! Ok this looks good now :-) I'll merge it! Thanks again! |
Hi, And I forgot one thing. You are right that people wouldn't need to have different fonts. I will add the code to change font for two label. Thank you : ) |
It's up to you, you're welcome to change the code again if you have the time :-) Just submit another PR |
add the minDistance and maxDistance to keep the distance between two point.