Comments (7)
I'd like to help with this. Can't be sure when I'll get to it, but if someone else has time before I do they can feel free to steal it.
from reactiveanimation.
Should this use the same RAN
struct, or should it be separated into something like RANView
and RANConstraint
? The former would be get a little icky implementation-wise, but the latter feels like you're repeating something that can be inferred anyways.
from reactiveanimation.
@indragiek It should definitely use a different type but! we can cheat and change RAN
into a free function that selects the right type.
from reactiveanimation.
@jspahrsummers Nice 👍
from reactiveanimation.
@jspahrsummers If I make RAN
a free function to have it choose the correct type, how will accessing the properties work? RANView
has alpha
, bounds
, etc. and RANConstraint
would only have constant
. Making both conform to a common protocol doesn't seem feasible.
from reactiveanimation.
@jspahrsummers Never mind, that was dumb. Forgot about function overloading.
from reactiveanimation.
I was making my own local copy to use in one of my projects and there's a problem with the current PR & animating constraints, mainly because those animations require that the constraint value be set outside of animateWithDuration
. Furthermore you have to call view.layoutIfNeeded()
in the animation block. That means the current implementation for constraints in the PR and branch doesn't animate.
The way I was thinking about doing is was:
- Add a view property to the constraints struct
- call
constraint.view?.layoutIfNeeded()
in the binding
public struct ReactiveConstraint {
private weak var constraint: NSLayoutConstraint?
private weak var view: UIView?
private let willDealloc: SignalProducer<(), NoError>
public init(_ constraint: NSLayoutConstraint, view: UIView?) {
self.constraint = constraint
self.view = view
self.willDealloc = constraint.rac_willDeallocSignal()
.toSignalProducer()
.map { _ in () }
.flatMapError {
fatalError("rac_willDeallocSignal failed with error: \($0)")
()
}
}
}
public func <~ (constraint: ReactiveConstraint, signal: Signal<CGFloat, NoError>) -> Disposable {
let disposable = CompositeDisposable()
let constraintDisposable = constraint.willDealloc.startWithCompleted {
disposable.dispose()
}
disposable.addDisposable(constraintDisposable)
let signalDisposable = signal.observe(Observer(
next: {
constraint.constraint?.constant = $0
constraint.view?.layoutIfNeeded()
},
completed: {
disposable.dispose()
}
))
disposable.addDisposable(signalDisposable)
return disposable
}
Now my constraint animations work without having to change the animateEach
method.
from reactiveanimation.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactiveanimation.