Skip to content

Commit

Permalink
fix: remove jank
Browse files Browse the repository at this point in the history
  • Loading branch information
vcellu committed Sep 8, 2022
1 parent 9c79962 commit 793e12a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions ios/GrabberView.swift
Expand Up @@ -14,13 +14,14 @@ class GrabberView: UIView {
weak var containerView: ContainerView?
weak var headerView: HeaderView?
weak var button: UIView?
weak var footerView: FooterView?
weak var totalsView: TotalsView?
weak var scrollView: UIScrollView?
weak var guideLineView: GuideLineView?
var pressed = false
var trim:CGFloat = 0;
var timer: Timer?
var currentTranslation = CGPoint.zero
var shouldExpand = false

var linePath = UIBezierPath()
var guidePath = UIBezierPath()
Expand Down Expand Up @@ -84,6 +85,7 @@ class GrabberView: UIView {
switch sender.state {
case .began:
currentTranslation = CGPoint.zero
shouldExpand = true
pressed = true
if let guideLineView = guideLineView {
guideLineView.pressed(isPressed: true)
Expand Down Expand Up @@ -120,8 +122,8 @@ class GrabberView: UIView {
container.updateSize(colIdx)
}

if let footerView = footerView {
footerView.updateSize(translation, withColumn: colIdx)
if let totalsView = totalsView {
totalsView.updateSize(translation, withColumn: colIdx)
}
return true
}
Expand All @@ -136,7 +138,6 @@ class GrabberView: UIView {
currentOffset.x += translation.x
scrollView.setContentOffset(currentOffset, animated: false)
scrollView.flashScrollIndicators()
broadcastUpdate()
currentTranslation = translation;
if let containerView = containerView {
if scrollView.contentSize.width > containerView.frame.width {
Expand All @@ -147,6 +148,7 @@ class GrabberView: UIView {
}
}
} else if isLast && translation.x < -0.01 {
shouldExpand = false
endTimer()
}
}
Expand Down Expand Up @@ -199,6 +201,9 @@ class GrabberView: UIView {
if let guideLineView = guideLineView {
guideLineView.pressed(isPressed: true)
}
if !shouldExpand {
return
}
timer = Timer.scheduledTimer(withTimeInterval: 0.0016, repeats: true) { t in
self.currentTranslation.x = 1
let _ = self.broadcastTranslation(self.currentTranslation)
Expand Down

0 comments on commit 793e12a

Please sign in to comment.