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
/* | |
Copyright 2016-present The Material Motion Authors. All Rights Reserved. | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
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
#if (arch(i386) || arch(x86_64)) && os(iOS) | |
@_silgen_name("UIAnimationDragCoefficient") func UIAnimationDragCoefficient() -> Float | |
func simulatorDragCoefficient() -> CGFloat { | |
let drag = UIAnimationDragCoefficient() | |
if drag > 1 { | |
return CGFloat(drag) | |
} | |
return 1 | |
} |
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
# Streams | |
let drag$ = .... | |
aggregator.write(drag$.x().rubberBanded(0, 100), | |
to: propertyOf(view).center) | |
# Plan/Performer |
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
/* | |
Copyright 2016-present The Material Motion Authors. All Rights Reserved. | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
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
/* | |
Copyright 2016-present The Material Motion Authors. All Rights Reserved. | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
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
MotionAggregator is active: true | |
Child is active: true | |
tween(duration: 5.0, values: UIExtendedSRGBColorSpace 1 0 0 1, UIExtendedSRGBColorSpace 1 0 1 1, UIExtendedSRGBColorSpace 1 0 0 1) | |
-> <CAKeyframeAnimation:0x608000223060; keyPath = backgroundColor; values = ( | |
"<CGColor 0x6000000a8340> [<CGColorSpace 0x600000429520> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1; extended range)] ( 1 0 0 1 )", | |
"<CGColor 0x6000000a8640> [<CGColorSpace 0x600000429520> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1; extended range)] ( 1 0 1 1 )", | |
"<CGColor 0x6000000a8340> [<CGColorSpace 0x600000429520> (kCGColorSpaceICCBased; kCGColorSpaceModelRGB; sRGB IEC61966-2.1; extended range)] ( 1 0 0 1 )" | |
); duration = 5> '6591F5BE-E262-447D-A04B-6967BAF32095' to CALayer::0x60000003e940.backgroundColor | |
springTo(destination: 400.0, source: UIView::0x7f90b59143c0, property: centerY) | |
-> 333.5 to UIView::0x7f90b59143c0.centerY |
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
let tween = Tween<CGFloat>( | |
duration: 0.3, | |
values: [0, 5], | |
timeline: timeline | |
) | |
runtime.addPlan(tween, | |
to: layer, | |
property: tweenPropertyOf(layer).position) |
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
/* | |
Copyright 2016-present The Material Motion Authors. All Rights Reserved. | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
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
public typealias MaterialRestableStream<T> = (stream: MaterialStream<T>, atRest: MaterialStream<Bool>) | |
public func drag(_ pan: UIPanGestureRecognizer) -> MaterialRestableStream<CGPoint> { | |
return (MaterialStream<CGPoint>(named: #function) { observer in | |
let dragObserver = DragObserver { | |
observer.next(pan.location(in: pan.view!.superview!)) | |
} | |
pan.addTarget(dragObserver, action: #selector(DragObserver.didPan)) |
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
public class MaterialRestableStream<T>: MaterialStream<T> { | |
public var atRest = true { | |
didSet { | |
if atRest != oldValue { | |
for listener in listeners { | |
(listener as! AnyObserver<Bool>).next(atRest) | |
} | |
} | |
} |