Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling the shutdownLabel or pauseLabel function does not stop the animation? #200

Closed
theFons opened this issue Nov 5, 2017 · 2 comments

Comments

@theFons
Copy link

theFons commented Nov 5, 2017

Usage Details

  • Language: SWIFT
  • Platform: AppleTV

Expected Behavior

calling the shutdownLabel or pauseLabel should stop the animation

Actual Behavior

Even after calling those functions, the scrolling continues

Steps to Reproduce the Problem

I'm using a custom class to detect when the animation reaches the home position.

class CustomMarqueeLabel : MarqueeLabel {
    open var returned : ((Bool)->Void)?
    override func labelReturnedToHome(_ finished: Bool) {
        super.labelReturnedToHome(finished)
        if returned != nil {
            returned!(finished)
        }
    }
}

Then in the main code.

scrollingLabel.text = String(mediacontent)
scrollingLabel.type = .continuous
scrollingLabel.speed = .rate(300)
scrollingLabel.fadeLength = 300.0
scrollingLabel.leadingBuffer = 1920
scrollingLabel.trailingBuffer = 1920
scrollingLabel.font = UIFont(name: "Helvetica", size: fontsize)

scrollingLabel.returned = {completed in
    self.scrollingLabel.shutdownLabel()
}

What am i doing wrong ?

@cbpowell
Copy link
Owner

Sorry for the slow reply - I'm not sure exactly what's causing your problem, but I have a few ideas. Either my recent changes to the animation handling has broken shutdownLabel, or something else is causing the scroll animation to trigger. Also possible the closure you're using could make something weird happen, although I can't say for sure (I'll have to try it).

In the interim, perhaps instead you could try setting the holdScrolling property to true from the start? (Like in your main code block) That will prevent automatic scrolling and subsequent loops, but then you can call triggerScrollStart at the appropriate time and the label will complete only one loop.

@cbpowell
Copy link
Owner

cbpowell commented Jun 8, 2018

Sorry it took so long, but I figured this one out and it's fixed in release 3.1.6. The issue was that calling shutdownLabel() removes the any in-flight animations, which is detected in the scroll completion block and breaks the repeating loop of adding another animation. But your method calls shutdownLabel in between animations, so there was no incomplete animation to detect and the loop just happily continued.

I fixed the issue by checking if the scrollCompletionBlock has been set to nil, and if so aborting the next loop.

@cbpowell cbpowell closed this as completed Jun 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants