Giter Club home page Giter Club logo

Comments (7)

nezhyborets avatar nezhyborets commented on June 14, 2024 1

It is simply a converter from single value of type UIViewAnimationCurve to single value of type UIViewAnimationOptions. You could do, for example:

let animationCurve = UIViewAnimationCurve.easeInOut
let animationOption = viewAnimationOptionForCurve(curve: animationCurve)
let options = [.beginFromCurrentState, option]

from typist.

totocaster avatar totocaster commented on June 14, 2024 1

Hey, thanks for opening issue! Typist is designed to be used with UIViewPropertyAnimator (see below) rather older UIView animation blocks.

UIViewPropertyAnimator(duration: TimeInterval, curve: UIViewAnimationCurve, animations: (() -> Void)? = nil)

However, I'll consider adding few other representations for curves for pre-iOS 10 compatibility reasons.

from typist.

nezhyborets avatar nezhyborets commented on June 14, 2024

I used this which seems right to me https://gist.github.com/miguellara/9e498715ee93540d79e9. I would suggest that it should be included to Typist

from typist.

kgn avatar kgn commented on June 14, 2024

@nezhyborets does this work for multiple values like [.beginFromCurrentState, .curveEaseInOut]?

from typist.

kgn avatar kgn commented on June 14, 2024

Updated for Swift3

func animationOptions(fromAnimationCurve curve: UIViewAnimationCurve) -> UIViewAnimationOptions {
    switch (curve) {
        case .easeInOut: return UIViewAnimationOptions.curveEaseInOut
        case .easeIn: return UIViewAnimationOptions.curveEaseIn
        case .easeOut: return UIViewAnimationOptions.curveEaseOut
        case .linear: return UIViewAnimationOptions.curveLinear
    }
}

from typist.

kgn avatar kgn commented on June 14, 2024

@totocaster I switched to this code

func keyboardWillShow(options: Typist.KeyboardOptions) {
    self.loginButtonConstraint.constant = -options.endFrame.height-Style.Size.Padding
    UIViewPropertyAnimator(duration: options.animationDuration, curve: options.animationCurve) {
        self.view.layoutIfNeeded()
    }.startAnimation()
}

but now getting this error

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unknown/Unsupported UIViewAnimationCurve type 7'

from typist.

totocaster avatar totocaster commented on June 14, 2024

@kgn I believe you have to keep reference to instance of UIViewPropertyAnimator while animation happens. If you don't wish to do so use UIViewPropertyAnimator .runningPropertyAnimator(withDuration:delay:options:animations:completion:). It also start animation automatically.

See UIViewPropertyAnimator docs here.

from typist.

Related Issues (16)

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.