Skip to content

Commit f854be8

Browse files
authored
Merge pull request #202 from ikesyo/isRemovedOnCompletion-and-fillMode
Use `isRemovedOnCompletion = false` and `fillMode = kCAFillModeForwards` for `.left` and `.right` types
2 parents 47c5c9a + 659aeeb commit f854be8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/Swift/MarqueeLabel.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,7 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate {
695695
FadeStep(timeStep: -0.2, edgeFades: [.leading, .trailing]), // Maintain fade state until 0.2 sec before reaching away position
696696
ScrollStep(timeStep: animationDuration, timingFunction: animationCurve, // Away position, using animationCurve transition, with only leading edge faded in
697697
position: .away, edgeFades: .leading),
698-
ScrollStep(timeStep: 60*60*24*365.0, // "Delay" at away, for huge time to effectie stay at away permanently
699-
position: .away, edgeFades: .leading),
698+
ScrollStep(timeStep: animationDelay, position: .away, edgeFades: .leading), // "Delay" at away, maintaining fade state
700699
]
701700
}
702701
}
@@ -876,6 +875,11 @@ open class MarqueeLabel: UILabel, CAAnimationDelegate {
876875
// Perform scroll animation
877876
scroller.anim.setValue(true, forKey: MarqueeKeys.CompletionClosure.rawValue)
878877
scroller.anim.delegate = self
878+
if type == .left || type == .right {
879+
// Make it stay at away permanently
880+
scroller.anim.isRemovedOnCompletion = false
881+
scroller.anim.fillMode = kCAFillModeForwards
882+
}
879883
sublabel.layer.add(scroller.anim, forKey: "position")
880884

881885
CATransaction.commit()

0 commit comments

Comments
 (0)