WorldDownTown / RangeSeekSlider

RangeSeedSlider provides a customizable range slider like a UISlider.
MIT License
755 stars 282 forks source link

Update label positions bug when disableRange is true. #94

Open vladpre92 opened 4 years ago

vladpre92 commented 4 years ago

New Issue Checklist

Issue Description

Hi guys! When disableRange = true, this library uses the rightHandle to choose a value. I found a problem with maxLabel boundaries when labels are not fixed. When rightHandle is set to minimum value, the label exceeds slider frame and position it's not adjusted. I think this scenario it's not covered inside updateLabelPositions method. You can see this case in the attached screenshot. Any fix for this?

Thank you!

Environment

IMG_0529

jigneshradadiya commented 4 years ago

I got the solution for this issue. Just update below code in RangeSeekSlider.swift file

/ Old code let newMinLabelCenter: CGPoint = CGPoint(x: leftHandle.frame.midX, y: leftHandle.frame.maxY + (minLabelTextSize.height/2) + labelPadding) let newMaxLabelCenter: CGPoint = CGPoint(x: rightHandle.frame.midX, y: rightHandle.frame.maxY + (maxLabelTextSize.height/2) + labelPadding)/ //Try this // Updated code to set labels above the handle let YPossitionMin=leftHandle.frame.midY - (minLabelTextSize.height + labelPadding) let YPossitionMax=rightHandle.frame.midY - (maxLabelTextSize.height + labelPadding) let newMinLabelCenter: CGPoint = CGPoint(x: leftHandle.frame.midX, y: YPossitionMin) let newMaxLabelCenter: CGPoint = CGPoint(x: rightHandle.frame.midX, y:YPossitionMax)