-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d441a23
commit aaf2333
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import TRX | ||
import UIKit | ||
|
||
struct ExampleObject { | ||
var value: Double | ||
} | ||
|
||
var object = ExampleObject(value: 0) | ||
var anOtherObject = object | ||
|
||
struct ExampleLayer { | ||
var position: CGPoint | ||
} | ||
|
||
var layer = ExampleLayer(position: CGPoint.zero) | ||
var myView = UIView() | ||
var someFrame = CGRect() | ||
|
||
Tween(from: 0, to: 20, time: 0.3) { | ||
object.value = $0 | ||
}.start() | ||
|
||
1.trx(to: 20) { object.value = $0 }.start() | ||
|
||
Tween(from: CGPoint.zero, to: CGPoint(x: 20, y: 15), time: 0.3) { | ||
layer.position = $0 | ||
}.start() | ||
|
||
Tween(from: 0, | ||
to: 1, | ||
time: 0.3, | ||
delay: 0.1, | ||
ease: Ease.Elastic.easeOut, | ||
key: "MyOwnKey", | ||
onStart: { print("start") }, | ||
onComplete: { done in print("complete and done: \(done)") }) { value in | ||
object.value = value | ||
}.start() | ||
|
||
TimeLine(tweens: [ | ||
1.trx(to: 20) { object.value = $0 }, | ||
30.trx(to: 40) { object.value = $0 }, | ||
40.trx(to: 50) { object.value = $0 }, | ||
]).start() | ||
|
||
|
||
let timeline: TimeLine = [ | ||
1.trx(to: 20) { object.value = $0 }: 0, | ||
30.trx(to: 40) { anOtherObject.value = $0 }: -0.5, | ||
40.trx(to: 50) { anOtherObject.value = $0 }: -0.5 | ||
] | ||
timeline.start() | ||
|
||
let tween = Tween(from: 0, | ||
to: 1, | ||
time: 0.5) { print($0) } | ||
|
||
tween.scale = 2 // duration: 1s | ||
tween.duration = 2.0 // scale: 4 | ||
|
||
myView.trxCenter(to: CGPoint(x: 10, y: 15)) | ||
|
||
myView.trxCenter(from: CGPoint.zero) | ||
|
||
myView.trxFrame(to: someFrame) | ||
|
||
myView.trxFrame(to: someFrame) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<playground version='5.0' target-platform='ios'> | ||
<timeline fileName='timeline.xctimeline'/> | ||
</playground> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters