Digital ACT-191 ONEAPP-6830 story: minor changes

This commit is contained in:
vasavk 2024-03-21 17:29:10 +05:30
parent 22d82fac04
commit 39a4c5040b

View File

@ -135,21 +135,11 @@ open class CarouselScrollbar: View {
private let activeOpacity: Float = 0.15
private let defaultOpacity: Float = 1
internal var containerView = View().with {
$0.translatesAutoresizingMaskIntoConstraints = false
}
internal var trackView = View().with {
$0.translatesAutoresizingMaskIntoConstraints = false
}
internal var leftActiveOverlay = View().with {
$0.translatesAutoresizingMaskIntoConstraints = false
}
internal var rightActiveOverlay = View().with {
$0.translatesAutoresizingMaskIntoConstraints = false
}
internal var thumbView = View().with {
$0.translatesAutoresizingMaskIntoConstraints = false
}
internal var containerView = View()
internal var trackView = View()
internal var leftActiveOverlay = View()
internal var rightActiveOverlay = View()
internal var thumbView = View()
internal var rightActiveOverlayLayer: CALayer = CALayer()
internal var leftActiveOverlayLayer: CALayer = CALayer()
@ -293,6 +283,25 @@ open class CarouselScrollbar: View {
rightActiveOverlayLayer.frame = .init(origin: .init(x: 0, y: 20), size: .init(width: rightActiveOverlay.frame.size.width, height: trackViewHeight))
}
private func checkPositions() {
totalPositions = Int (ceil (Double(numberOfSlides ?? 1) / Double(_selectedLayout.value)))
}
private func scrollThumbToPosition(_ position: Int?) {
setThumb(at: position)
onScrubberDidChange?(position ?? 1)
}
private func setThumb(at position: Int?) {
UIView.animate(withDuration: 0.1, delay: 0.0, options: .curveLinear, animations: {
self.thumbView.frame.origin.x = CGFloat(Float((position ?? 1) - 1) * self.computedWidth) + self.trackView.frame.origin.x
self.updateActiveOverlays()
})
}
//--------------------------------------------------
// MARK: - Gesture Methods
//--------------------------------------------------
// Drag scrollbar thumb to move it to the left or right.
// Upon releases of drag, the scrollbar thumb snaps to the closest full position and the scrollbar returns to original size without delay.
@objc func onScrubberDrag(_ sender: UIPanGestureRecognizer) {
@ -344,20 +353,4 @@ open class CarouselScrollbar: View {
}
})
}
private func checkPositions() {
totalPositions = Int (ceil (Double(numberOfSlides ?? 1) / Double(_selectedLayout.value)))
}
private func scrollThumbToPosition(_ position: Int?) {
setThumb(at: position)
onScrubberDidChange?(position ?? 1)
}
private func setThumb(at position: Int?) {
UIView.animate(withDuration: 0.1, delay: 0.0, options: .curveLinear, animations: {
self.thumbView.frame.origin.x = CGFloat(Float((position ?? 1) - 1) * self.computedWidth) + self.trackView.frame.origin.x
self.updateActiveOverlays()
})
}
}