GithubHelp home page GithubHelp logo

marmelroy / interpolate Goto Github PK

View Code? Open in Web Editor NEW
1.8K 37.0 69.0 1.03 MB

Swift interpolation for gesture-driven animations

License: MIT License

Objective-C 1.89% Swift 87.65% Ruby 6.25% Shell 4.21%
interpolation gesture-recognizer swift gesture-driven-animations animation ios interactive

interpolate's People

Contributors

bcylin avatar delba avatar farktronix avatar hmazelier avatar leomehlig avatar marmelroy avatar marmelroyspotify avatar min avatar richy486 avatar romanroibu avatar taraxe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

interpolate's Issues

Interpolating a ProgressView from top to Bottom leads to Fuzzy UI Object

@marmelroy
I tried this all day yesterday with the JWGCircleCounter) and CircleProgressView

Steps to Reproduce

  • Instantiate a CircleProgressView or any other animatable circle view to the top right of your view.

  • On tap, interpolate the object down to the center bottom of the screen.

  • The object on top right will be perfectly nice and crisp.

  • When it gets to the bottom, it will be blury and fuzzy

class ViewController: UIViewController {
    
    var circle: CircleProgressView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.addRecordButton()
    }
    
    func addRecordButton() {
        self.circle = CircleProgressView(x: self.view.size.width - 56, y: 29, w: 30, h: 30)
        self.circle.trackBackgroundColor = .blue
        self.circle.trackBorderWidth = 3
        self.circle.backgroundColor = .clear
        self.circle.layer.cornerRadius = self.circle.size.width / 2
        
        let tap = UITapGestureRecognizer(target: self, action: #selector(self.tap))
        self.circle.addGestureRecognizer(tap)
        
        self.view.addSubview(circle)
    }
    
    func tap() {
        self.interpolate()
    }
    
    func interpolate() {
        let newframe = CGRect(x: self.view.centerX - 37.5, y: self.view.size.height - 100, w: 75, h: 75)
        let interpolate = Interpolate(from: self.circle.frame, to: newframe) { (newframe) in
            self.circle.frame = newframe
        }
        interpolate.animate(duration: 5)
    }
}

Mid Vector

I was hoping Interpolate could make my life a lot easier with my current task.
I have 3 screens inside a UIScrollView
So three pages.
Each pages is a specific color.
I need to animate the background color as I scroll.
It seems that interpolate only allows two vectors. To and From
I need to define a third: Mid.
So if progress was at 0 then the screen would be blue.
progress was set to 0.5 the screen would be red
progress set to 1 would be green.

Is this possible with the current version?

Interpolate not working

Hi ! :)
I have the problem that my code below is not printing any values. I'm using Xcode 8 and Swift 3.


let i = Interpolate(from: 100.0, to: 3.0, apply: { n in print(n) })
        i.animate(duration: 3.0)

SpringInterpolation does not complete

@marmelroy
eg. SpringInterpolation(damping: 30.0, velocity: 0.0, mass: 1.0, stiffness: 100.0)
Hey, I find that using Spring Interpolations, my animations do not finish at their destination even though progress = 100%. Instead they are always near completion.

Why is that?

start multiple animations at the same time

The example app has basically

    func progress(scrollProgress:CGFloat) {
        let groundProgress = scrollProgress * 1.5
        backgroundColorChange?.progress = scrollProgress
        logoAlpha?.progress = scrollProgress
        groundPosition?.progress = groundProgress
        bojackPosition?.progress = groundProgress
        bojackShadowPosition?.progress = max(groundProgress - 1, 0)
    }

So I can set the progress with procress(0) and procress(1) for the whole interpolations - but how I can animate that? Running animate on all interpolations feels wrong. Something along the lines of this would be great:

progress(0)
UIView.animate(...) {
  progress(1)
}

Swift3

it'd be cool to have a swift 3 version, if you have any interest to create a branch i would like to help with that.

Interpolate not running with Double values

For some reason, the following doesn't work at all:

let i = Interpolate(from: 100.0, to: 3.0, apply: { n in print(n) })
i.animate(duration: 3.0)

but this does:

i = Interpolate(from: CGFloat(100.0), to: CGFloat(3.0), apply: { n in print(n) })
i.animate(duration: 3.0)

I'm using version 0.2.0 with Swift 2.3. I can't figure this out without getting pretty deep into the code but the init() seems to set up the instance variables identically. I'm lost, but I'd love to know what the problem is โ€” hopefully on my end.

animating constraints

Is there also a way to animate constraints with Interpolate?
Would be nice to have an example for that.

I assume it's just calling layoutIfNeeded() after assigning the change inside Interpolate closure?

Swift 3

Any plans to include a swift 3 branch?

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.