Skip to content

Commit 2c7ae28

Browse files
committed
Add documentation for public methods and properties.
1 parent fb41737 commit 2c7ae28

4 files changed

+26
-7
lines changed

Sources/SpringMotionLayer.swift

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ open class SpringMotionLayer: CALayer {
2020
/// Moves the layer to the specified point with spring animation.
2121
///
2222
/// - 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.
2423
public func move(to point: CGPoint) {
2524
motionStates = motionPhysics.calculateAllStates(
2625
from: getCurrentMotionState(),

Sources/SpringMotionView-iOS.swift

+9-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@ import UIKit
1111

1212
open class SpringMotionView: UIView {
1313

14-
public var onPositionUpdate: ((CGPoint) -> Void)?
15-
14+
/// Configuration that adjusts the spring physics behind the animation.
1615
public var configuration: SpringConfiguration = .default {
1716
didSet {
1817
motionPhysics = .init(configuration: configuration, timeStep: timeStep)
1918
}
2019
}
2120

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.
2229
public func move(to point: CGPoint) {
2330
destinationPoint = point
2431
}

Sources/SpringMotionView-macOS.swift

+9-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@ import AppKit
1111

1212
open class SpringMotionView: NSView {
1313

14-
public var onPositionUpdate: ((NSPoint) -> Void)?
15-
14+
/// Configuration that adjusts the spring physics behind the animation.
1615
public var configuration: SpringConfiguration = .default {
1716
didSet {
1817
motionPhysics = .init(configuration: configuration, timeStep: timeStep)
1918
}
2019
}
2120

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.
2229
public func move(to point: NSPoint) {
2330
destinationPoint = point
2431
}

Sources/SpringMotionWindow.swift

+8-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import AppKit
1111

1212
open class SpringMotionWindow: NSWindow {
1313

14+
/// Configuration that adjusts the spring physics behind the animation.
1415
public var configuration: SpringConfiguration = .default {
1516
didSet {
1617
motionPhysics = .init(configuration: configuration, timeStep: 0.008)
@@ -33,12 +34,17 @@ open class SpringMotionWindow: NSWindow {
3334
// MARK: - API
3435
public extension SpringMotionWindow {
3536

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.
3640
func move(to point: NSPoint) {
3741
destinationPoint = point
3842
}
3943

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.
4248
func pinToWindow(_ anchorWindow: NSWindow, offsetFromCenter: NSPoint) {
4349
unpinFromWindow()
4450
move(to: anchorWindow.frame.center + offsetFromCenter)

0 commit comments

Comments
 (0)