     private func elementFrame(forIndex index: Int) -> CGRect {
         let elementWidth = (width - totalInsetSize) / CGFloat(normalSegmentCount)
         let x = CGFloat(isLayoutDirectionRightToLeft ? lastIndex - index : index) * elementWidth
+        
         return CGRect(x: x + indicatorViewInset,
                       y: indicatorViewInset,
                       width: elementWidth,

        return Int(distances.firstIndex(of: distances.min()!)!)
    }
    private func moveIndicatorView() {
        indicatorView.frame = normalSegments[self.index].frame
        layoutIfNeeded()
    }
    
    // MARK: Action handlers

        }
        set {
            layer.cornerRadius = newValue
            updateCornerRadii()
        }
    }
    /// The indicator view's background color.
