Code Monkey home page Code Monkey logo

Comments (4)

icanzilb avatar icanzilb commented on July 22, 2024

can you please paste in a chunk of code of how you add the animations and how you remove them so I can try to reproduce the problem?

from easyanimation.

iaomw avatar iaomw commented on July 22, 2024

Sorry, not the same as I expected before. It something like that below. I will change the title. While I am touching too fast, the completion block will not work.

func transformToTouching() { //Response to touching event

    self.setHighlighted(true, animated: true)

    self.animationQueue.removeAll(keepCapacity: true)

    EAAnimationDelayed.animations.map {

        $0.cancelAnimationChain()
    }

    self.spriteLayer.removeAllAnimations()

    self.chainAnimation({ () -> Void in

        self.spriteLayer.fillColor = ...
        self.spriteLayer.path = ...

    }, duration: 0.3)
}

typealias AnimationBlock = () -> Void
typealias AnimationPiece = (animation:AnimationBlock, duration: NSTimeInterval)

var animating:Bool = false
var animationQueue = [AnimationPiece]()

func chainAnimation(animation: AnimationBlock, duration: NSTimeInterval) {

    self.animationQueue.append((animation:animation, duration: duration))

    self.feedAnimation()
}

func feedAnimation() {

    if self.animating {

        return
    }

    if let some = self.animationQueue.first {

        self.animationQueue.removeAtIndex(0)

        self.animating = true

        UIView.animateWithDuration(some.duration, delay: 0.0, options: UIViewAnimationOptions.CurveEaseInOut, animations: some.animation, completion: { (done: Bool) -> Void in // Not work while too fast

            self.animating = false

            self.feedAnimation()
        })

    } else {

        return
    } //
}

from easyanimation.

icanzilb avatar icanzilb commented on July 22, 2024

what I see at first sight is that you never actually use the EasyAnimation API to create chains - animateAndChainWithDuration(...). You can cancel only custom EA chains, since the "normal" animations you create with the UIKit API aren't cancelable (but not a bad idea to think if it's possible to do that). Review again the example in the README: https://github.com/icanzilb/EasyAnimation#cancel-chain-animations

from easyanimation.

iaomw avatar iaomw commented on July 22, 2024

I really want to use your chain, but it doesn't work out while I chain them from different place. #9
Oops, as the block, we can comment it, it doesn't matter for the phenomenon. 😂

EAAnimationDelayed.animations.map {

        $0.cancelAnimationChain()
}

from easyanimation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.