marmelroy / interpolate Goto Github PK
View Code? Open in Web Editor NEWSwift interpolation for gesture-driven animations
License: MIT License
Swift interpolation for gesture-driven animations
License: MIT License
@marmelroy
Is it possible to Interpolate the Status bar color from .default to .lightContent and vis-versa?
@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)
}
}
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?
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)
@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?
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)
}
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.
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.
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?
Any plans to include a swift 3 branch?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.