File tree 4 files changed +26
-7
lines changed
4 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,6 @@ open class SpringMotionLayer: CALayer {
20
20
/// Moves the layer to the specified point with spring animation.
21
21
///
22
22
/// - Parameter point: a `CGPoint` that defines the layer's destination and represents the layer's center point.
23
- /// - Parameter callback: a closure to call when spring motion has stopped.
24
23
public func move( to point: CGPoint ) {
25
24
motionStates = motionPhysics. calculateAllStates (
26
25
from: getCurrentMotionState ( ) ,
Original file line number Diff line number Diff line change @@ -11,14 +11,21 @@ import UIKit
11
11
12
12
open class SpringMotionView : UIView {
13
13
14
- public var onPositionUpdate : ( ( CGPoint ) -> Void ) ?
15
-
14
+ /// Configuration that adjusts the spring physics behind the animation.
16
15
public var configuration : SpringConfiguration = . default {
17
16
didSet {
18
17
motionPhysics = . init( configuration: configuration, timeStep: timeStep)
19
18
}
20
19
}
21
20
21
+ /// A closure that is called on every step of animation.
22
+ /// Within it you should update any relevant constraints to position the view according
23
+ /// to the `CGPoint` parameter passed into the closure. This point represents the center of the view.
24
+ public var onPositionUpdate : ( ( CGPoint ) -> Void ) ?
25
+
26
+ /// Moves the view to the specified point with spring animation.
27
+ ///
28
+ /// - Parameter point: a `CGPoint` that defines the view's destination and represents the view's center point.
22
29
public func move( to point: CGPoint ) {
23
30
destinationPoint = point
24
31
}
Original file line number Diff line number Diff line change @@ -11,14 +11,21 @@ import AppKit
11
11
12
12
open class SpringMotionView : NSView {
13
13
14
- public var onPositionUpdate : ( ( NSPoint ) -> Void ) ?
15
-
14
+ /// Configuration that adjusts the spring physics behind the animation.
16
15
public var configuration : SpringConfiguration = . default {
17
16
didSet {
18
17
motionPhysics = . init( configuration: configuration, timeStep: timeStep)
19
18
}
20
19
}
21
20
21
+ /// A closure that is called on every step of animation.
22
+ /// Within it you should update any relevant constraints to position the view according
23
+ /// to the `CGPoint` parameter passed into the closure. This point represents the center of the view.
24
+ public var onPositionUpdate : ( ( NSPoint ) -> Void ) ?
25
+
26
+ /// Moves the view to the specified point with spring animation.
27
+ ///
28
+ /// - Parameter point: a `CGPoint` that defines the view's destination and represents the view's center point.
22
29
public func move( to point: NSPoint ) {
23
30
destinationPoint = point
24
31
}
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import AppKit
11
11
12
12
open class SpringMotionWindow : NSWindow {
13
13
14
+ /// Configuration that adjusts the spring physics behind the animation.
14
15
public var configuration : SpringConfiguration = . default {
15
16
didSet {
16
17
motionPhysics = . init( configuration: configuration, timeStep: 0.008 )
@@ -33,12 +34,17 @@ open class SpringMotionWindow: NSWindow {
33
34
// MARK: - API
34
35
public extension SpringMotionWindow {
35
36
37
+ /// Moves the window to the specified point with spring animation.
38
+ ///
39
+ /// - Parameter point: a `CGPoint` that defines the window's destination and represents the window's center point.
36
40
func move( to point: NSPoint ) {
37
41
destinationPoint = point
38
42
}
39
43
40
- /// Starts following the given window.
41
- /// `offsetFromCenter` is the difference between this window's center and the anchor window's center.
44
+ /// Starts following the given window with a certain offset from its center.
45
+ ///
46
+ /// - Parameter anchorWindow: an `NSWindow` that this window will follow.
47
+ /// - Parameter offsetFromCenter: the difference between this window's center and the anchor window's center.
42
48
func pinToWindow( _ anchorWindow: NSWindow , offsetFromCenter: NSPoint ) {
43
49
unpinFromWindow ( )
44
50
move ( to: anchorWindow. frame. center + offsetFromCenter)
You can’t perform that action at this time.
0 commit comments