DKChainableAnimationKit icon indicating copy to clipboard operation
DKChainableAnimationKit copied to clipboard

Animation trouble using Timer

Open ghost opened this issue 8 years ago • 0 comments

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.

ghost avatar May 18 '17 16:05 ghost