Skip to content

Commit

Permalink
Nil completion block when animations are removed to fix memory leak […
Browse files Browse the repository at this point in the history
…common]
  • Loading branch information
cbpowell committed Sep 10, 2016
1 parent b97ec74 commit 7ac46e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sources/ObjC/MarqueeLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ - (NSArray *)controlPoints;
- (CGFloat)durationPercentageForPositionPercentage:(CGFloat)positionPercentage withDuration:(NSTimeInterval)duration;
@end

@interface MarqueeLabel()
@interface MarqueeLabel() <CAAnimationDelegate>

@property (nonatomic, strong) UILabel *subLabel;

Expand Down Expand Up @@ -525,6 +525,9 @@ - (void)returnLabelToOriginImmediately {

// Remove sublabel position animations
[self.subLabel.layer removeAllAnimations];

// Remove compeltion blocks
self.scrollCompletionBlock = nil;
}

- (void)scrollAwayWithInterval:(NSTimeInterval)interval {
Expand Down
3 changes: 3 additions & 0 deletions Sources/Swift/MarqueeLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,9 @@ public class MarqueeLabel: UILabel {

// Remove all sublabel position animations
sublabel.layer.removeAllAnimations()

// Remove completion block
scrollCompletionBlock = nil
}

private func scroll(interval: CGFloat, delay: CGFloat = 0.0, scroller: Scroller, fader: CAKeyframeAnimation?) {
Expand Down

0 comments on commit 7ac46e8

Please sign in to comment.