Skip to content
This repository has been archived by the owner on Jan 5, 2020. It is now read-only.

Animation trouble using Timer #30

Open
ghost opened this issue May 18, 2017 · 0 comments
Open

Animation trouble using Timer #30

ghost opened this issue May 18, 2017 · 0 comments

Comments

@ghost
Copy link

ghost commented May 18, 2017

Basically I have a sidemenu that I am using DKChainableAnimationKit to both show and hide my sidebar, which works perfect. However, I have noticed that when I've been using timers, the animation seem to crash. For instance, I have a timer that counts down from 10 to 0, basically by decreasing the global integer by 1, every second. When I make the countdown start, and click the button to show the sidebar - it suddenly disappears. To avoid this, I have been trying to do a .makeOrigin after the animation has been done - with no luck. I have also tried to do the countdown in the timer update function running async, also with no luck.

Any ideas on how I would approach this?

Here is my code:

Button for showing sidebar:
self.sideview.animation.moveX(350).easeInOutSine.animate(0.5)

Timer:
self.countdownText = Foundation.Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(ViewController.counter), userInfo: nil, repeats: true)

Counter Function:

func counter() {
            self.count = Int(self.count - 1) //When I add this line, the animation disappears (or the sidebar)
            self.newGameLabel.text = String(self.count) //This line works, without any error.
        }

    }

Could someone please help me to fix this? Much appreciated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants