1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-09-11 13:15:35 +03:00

Testing UI update on animation progress

This commit is contained in:
Victor Sukochev 2016-09-06 23:05:38 +06:00
parent 0be0d4d001
commit 7637b59fc0
3 changed files with 17 additions and 1 deletions

View File

@ -233,6 +233,7 @@
</view>
<connections>
<outlet property="sceneView" destination="y1S-j5-FMS" id="Gys-cw-jYu"/>
<outlet property="slider" destination="Zi2-qo-k4Y" id="jKF-Vt-DvO"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="asF-Da-v23" userLabel="First Responder" sceneMemberID="firstResponder"/>

View File

@ -2,11 +2,16 @@ import UIKit
class PathExampleController: UIViewController {
@IBOutlet var sceneView: PathExampleView?
@IBOutlet var slider: UISlider?
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
sceneView?.testAnimation()
sceneView?.onScaleUpdate = { scale in
self.slider?.value = Float(scale)
}
}
@IBAction func onScaleUpdate(slider: UISlider) {

View File

@ -8,6 +8,8 @@ class PathExampleView: MacawView {
let sceneGroup: Group
let initialTransform: Transform
var onScaleUpdate: ((Double) -> ())?
required init?(coder aDecoder: NSCoder) {
let startPoint = Point(x: 150.0, y: 150.0)
@ -121,10 +123,18 @@ class PathExampleView: MacawView {
let rotation = GeomUtils.centerRotation(node: sceneGroup, angle: M_PI_4 / 4.0)
let superposition = GeomUtils.concat(t1: initialTransform, t2: rotation)
// animation = group.placeVar.animation((initialTransform >> initialTransform.scale(sx: 0.15, sy: 0.15)).t(10.0))
animation = sceneGroup.placeVar.animation((initialTransform >> initialTransform.scale(sx: 0.15, sy: 0.15)).t(10.0))
// let test = Text(text: "Hello World!", place: .move(dx: 100, dy: 100))
super.init(node: sceneGroup, coder: aDecoder)
sceneGroup.placeVar.asObservable().subscribeNext { transform in
let a = transform.m11
let b = transform.m12
let sx = a / fabs(a) * sqrt(a * a + b * b)
self.onScaleUpdate?(sx)
}
}
func testAnimation() {