From a3f8a3e7a4c3ac34c2df9193804f0e736ce6f404 Mon Sep 17 00:00:00 2001 From: Sereivoan Yong Date: Fri, 2 Jul 2021 15:49:00 +0700 Subject: [PATCH] Make handles never exceeds `sliderLine` edges --- Sources/RangeSeekSlider.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/RangeSeekSlider.swift b/Sources/RangeSeekSlider.swift index 546b27d..3fa06ab 100644 --- a/Sources/RangeSeekSlider.swift +++ b/Sources/RangeSeekSlider.swift @@ -468,12 +468,12 @@ import UIKit let percentage: CGFloat = percentageAlongLine(for: value) // get the difference between the maximum and minimum coordinate position x values (e.g if max was x = 310, and min was x=10, difference is 300) - let maxMinDif: CGFloat = sliderLine.frame.maxX - sliderLine.frame.minX + let maxMinDif = sliderLine.frame.width - handleDiameter // now multiply the percentage by the minMaxDif to see how far along the line the point should be, and add it onto the minimum x position. let offset: CGFloat = percentage * maxMinDif - return sliderLine.frame.minX + offset + return sliderLine.frame.minX + handleDiameter / 2 + offset } private func updateLineHeight() {