Skip to content

Commit

Permalink
Remove animation, add delegate default impl
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihai Seremet committed Apr 10, 2023
1 parent d71d6bc commit 2a8b82d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 2 additions & 0 deletions DMScrollBar/DMScrollBarDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public protocol DMScrollBarDelegate: AnyObject {
// MARK: - DMScrollBarDelegate extension for Table View

public extension DMScrollBarDelegate {
func infoLabelText(forContentOffset contentOffset: CGFloat, scrollIndicatorOffset: CGFloat) -> String? { nil }

func scrollBarText(forContentOffset contentOffset: CGFloat, scrollIndicatorOffset: CGFloat) -> String? { nil }

/// This is a convenience method to get the header title for the section at the specified content offset. This method will not work for table views with custom headers
Expand Down
5 changes: 2 additions & 3 deletions DMScrollBar/ScrollBarIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ final class ScrollBarIndicator: UIView {
) {
guard let scrollBarLabelText = scrollBarLabelText, textConfig != nil else { return hideIndicatorLabel() }
if scrollBarLabelText == indicatorLabel?.text { return }
let animationDuration: TimeInterval = 0.15
indicatorLabel?.setup(text: scrollBarLabelText, direction: direction, duration: animationDuration)
UIView.animate(withDuration: animationDuration, animations: layoutIfNeeded)
indicatorLabel?.setup(text: scrollBarLabelText, direction: direction)
indicatorImageLabelStackView.layoutIfNeeded()
generateHapticFeedback(style: .light)
}

Expand Down
5 changes: 2 additions & 3 deletions DMScrollBar/ScrollBarInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ final class ScrollBarInfoView: UIView {

func updateText(text: String, direction: CATransitionSubtype?) {
if text == offsetLabel.text { return }
let animationDuration: TimeInterval = 0.15
offsetLabel.setup(text: text, direction: direction, duration: animationDuration)
UIView.animate(withDuration: animationDuration, animations: layoutIfNeeded)
offsetLabel.setup(text: text, direction: direction)
layoutIfNeeded()
generateHapticFeedback(style: .light)
}
}
4 changes: 2 additions & 2 deletions DMScrollBar/Utils/UILabel+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import UIKit
import QuartzCore

extension UILabel {
func setup(text: String, direction: CATransitionSubtype?, duration: TimeInterval) {
func setup(text: String, direction: CATransitionSubtype?) {
if let direction {
let animation = CATransition()
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
animation.type = CATransitionType.push
animation.subtype = direction
animation.duration = duration
animation.duration = 0.15
layer.add(animation, forKey: "pushTextChange")
}
self.text = text
Expand Down

0 comments on commit 2a8b82d

Please sign in to comment.