Skip to content

Commit

Permalink
2.0.1 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
poetmountain committed Apr 19, 2021
1 parent dd9cacc commit d3c8df5
Show file tree
Hide file tree
Showing 23 changed files with 188 additions and 124 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 2.0.1
- Fixed some retain cycles that were holding on to target objects
- Updated examples project

#### 2.0.0
- Support for Swift 5.0
- Updated syntax in MotionOptions for newer Swift naming conventions
Expand Down
12 changes: 8 additions & 4 deletions Examples/MotionExamples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 1000;
LastUpgradeCheck = 1240;
ORGANIZATIONNAME = "Poet & Mountain, LLC";
TargetAttributes = {
8BB379D31CFFA17D00A35AFD = {
Expand All @@ -241,7 +241,7 @@
};
buildConfigurationList = 8BB379CF1CFFA17D00A35AFD /* Build configuration list for PBXProject "MotionExamples" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -333,6 +333,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand All @@ -352,6 +353,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -377,7 +379,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -391,6 +393,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand All @@ -410,6 +413,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -428,7 +432,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand Down
4 changes: 2 additions & 2 deletions Examples/MotionExamples/ButtonsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import UIKit

protocol ButtonsViewDelegate {
protocol ButtonsViewDelegate: class {
func didStart()
func didStop()
func didPause()
Expand All @@ -24,7 +24,7 @@ public class ButtonsView: UIView {

var uiCreated: Bool = false

var delegate: ButtonsViewDelegate?
weak var delegate: ButtonsViewDelegate?


class func instanceFromNib() -> UIView {
Expand Down
10 changes: 6 additions & 4 deletions Examples/MotionExamples/Classes/AdditiveViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,13 @@ public class AdditiveViewController: UIViewController, ButtonsViewDelegate {
super.viewWillDisappear(animated)

group.stop()
for motion in group.motions {
group.remove(motion)
}
reverseGroup.stop()
}

deinit {
(view as! ButtonsView).delegate = nil
for motion in reverseGroup.motions {
reverseGroup.remove(motion)
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class BasicMotionViewController: UIViewController, ButtonsViewDelegate {


// setup motion
motion = Motion(target: xConstraint, duration: 1.0, easing: EasingQuadratic.easeInOut(), options: [.Reverse])
motion = Motion(target: xConstraint, duration: 1.0, easing: EasingQuadratic.easeInOut(), options: [.reverses])
.add(PropertyData("constant", 200.0))
.paused({ (motion) in
print("paused!")
Expand Down Expand Up @@ -66,11 +66,7 @@ public class BasicMotionViewController: UIViewController, ButtonsViewDelegate {

motion.stop()
}

deinit {
(view as! ButtonsView).delegate = nil
}





Expand Down
8 changes: 6 additions & 2 deletions Examples/MotionExamples/Classes/DynamicViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public class DynamicViewController: UIViewController, ButtonsViewDelegate {
for motion in motions {
motion.stop()
}
motions.removeAll()
}

deinit {
(view as! ButtonsView).delegate = nil
view.removeGestureRecognizer(tapRecognizer)
}

Expand Down Expand Up @@ -143,7 +143,7 @@ public class DynamicViewController: UIViewController, ButtonsViewDelegate {
}

let pt = gesture.location(in: self.view)
//print("gesture pt \(pt)")
print("gesture pt \(pt)")

var y_offset : CGFloat = 0.0

Expand All @@ -170,6 +170,10 @@ public class DynamicViewController: UIViewController, ButtonsViewDelegate {
motion_y.additive = true

let group = MotionGroup(motions: [motion_x, motion_y])
group.updated { [weak self] (group) in
guard let strong_self = self else { return }
//print("constraints \(strong_self.constraints)")
}
group.completed { [weak self] (group) in
guard let strong_self = self else { return }

Expand Down
10 changes: 5 additions & 5 deletions Examples/MotionExamples/Classes/GroupMotionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class GroupMotionViewController: UIViewController, ButtonsViewDelegate {


// setup motion
group = MotionGroup(options: [.Reverse])
group = MotionGroup(options: [.reverses])
.add(Motion(target: constraints["circleX"]!,
properties: [PropertyData("constant", 200.0)],
duration: 1.0,
Expand Down Expand Up @@ -82,12 +82,12 @@ public class GroupMotionViewController: UIViewController, ButtonsViewDelegate {
super.viewWillDisappear(animated)

group.stop()
for motion in group.motions {
group.remove(motion)
}
}

deinit {
(view as! ButtonsView).delegate = nil
}





Expand Down
29 changes: 15 additions & 14 deletions Examples/MotionExamples/Classes/PhysicsMotionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,7 @@ public class PhysicsMotionViewController: UIViewController, ButtonsViewDelegate


// setup motion
motion = PhysicsMotion(target: xConstraint, properties: [PropertyData("constant")], velocity: 300.0, friction: 0.72)
.paused({ (motion) in
print("paused!")
})
.resumed({ (motion) in
print("resumed!")
})
.completed({ (motion) in
print("completed!")
})
createMotion()

createdUI = true
}
Expand All @@ -69,10 +60,6 @@ public class PhysicsMotionViewController: UIViewController, ButtonsViewDelegate
motion.stop()
}

deinit {
(view as! ButtonsView).delegate = nil
}




Expand Down Expand Up @@ -119,6 +106,20 @@ public class PhysicsMotionViewController: UIViewController, ButtonsViewDelegate
}


private func createMotion() {
motion = PhysicsMotion(target: xConstraint, properties: [PropertyData("constant")], velocity: 300.0, friction: 0.72)
.paused({ (motion) in
print("paused!")
})
.resumed({ (motion) in
print("resumed!")
})
.completed({ (motion) in
print("completed!")
})
}


// MARK: - ButtonsViewDelegate methods

func didStart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class SequenceContiguousViewController: UIViewController, ButtonsViewDele
let group = MotionGroup(motions: [move_right, change_color])
let expand_group = MotionGroup(motions: [expand_width, expand_height, corner_radius])

sequence = MotionSequence(steps: [group, move_down, expand_group], options: [.Reverse])
sequence = MotionSequence(steps: [group, move_down, expand_group], options: [.reverses])
.stepCompleted({ (sequence) in
print("step complete")
})
Expand Down Expand Up @@ -101,10 +101,9 @@ public class SequenceContiguousViewController: UIViewController, ButtonsViewDele
super.viewWillDisappear(animated)

sequence.stop()
}

deinit {
(view as! ButtonsView).delegate = nil
for step in sequence.steps {
sequence.remove(step)
}
}


Expand Down
10 changes: 5 additions & 5 deletions Examples/MotionExamples/Classes/SequenceViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class SequenceViewController: UIViewController, ButtonsViewDelegate {


// setup motion
sequence = MotionSequence(options: [.Reverse])
sequence = MotionSequence(options: [.reverses])
.stepCompleted({ (sequence) in
print("step complete")
})
Expand All @@ -59,7 +59,7 @@ public class SequenceViewController: UIViewController, ButtonsViewDelegate {
duration: 0.7,
easing: EasingQuadratic.easeInOut())

let group = MotionGroup(motions: [down, color], options: [.Reverse])
let group = MotionGroup(motions: [down, color], options: [.reverses])

sequence.add(group)
}
Expand All @@ -81,11 +81,11 @@ public class SequenceViewController: UIViewController, ButtonsViewDelegate {
super.viewWillDisappear(animated)

sequence.stop()
for step in sequence.steps {
sequence.remove(step)
}
}

deinit {
(view as! ButtonsView).delegate = nil
}



Expand Down
2 changes: 1 addition & 1 deletion MotionMachine.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'MotionMachine'
s.version = '2.0.0'
s.version = '2.0.1'
s.swift_version = '5.0'
s.license = { :type => 'MIT' }
s.summary = 'An elegant, powerful, and modular animation library for Swift.'
Expand Down
5 changes: 3 additions & 2 deletions Sources/CATempo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ public class CATempo : Tempo {
*/
public override init() {
super.init()
displayLink = CADisplayLink.init(target: self, selector: #selector(update))
displayLink?.add(to: RunLoop.main, forMode: RunLoop.Mode(rawValue: RunLoop.Mode.common.rawValue))

displayLink = CADisplayLink(weakTarget: self, selector: #selector(update))
displayLink?.add(to: RunLoop.main, forMode: .common)
}

deinit {
Expand Down
16 changes: 8 additions & 8 deletions Sources/Motion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
// MARK: Motion state properties

/// The target object whose property should be moved.
private(set) public var targetObject: NSObject?
private(set) public weak var targetObject: NSObject?

/// A `MotionState` enum which represents the current state of the motion operation. (read-only)
private(set) public var motionState: MotionState
Expand Down Expand Up @@ -336,7 +336,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
public var reversing: Bool = false

/// Provides a delegate for updates to a Moveable object's status, used by `Moveable` collections.
public var updateDelegate: MotionUpdateDelegate?
public weak var updateDelegate: MotionUpdateDelegate?



Expand Down Expand Up @@ -522,7 +522,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
* - easing: An optional `EasingUpdateClosure` easing equation to use when moving the values of the given properties. `EasingLinear.easeNone()` is the default equation if none is provided.
* - options: An optional set of `MotionsOptions`.
*/
public convenience init(target targetObject: NSObject, properties: [PropertyData], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = .none) {
public convenience init(target targetObject: NSObject, properties: [PropertyData], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = MotionOptions.none) {

self.init(target: targetObject, properties: properties, statesForProperties: nil, duration: duration, easing: easing, options: options)

Expand All @@ -537,7 +537,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
* - easing: An optional `EasingUpdateClosure` easing equation to use when moving the values of the given properties. `EasingLinear.easeNone()` is the default equation if none is provided.
* - options: An optional set of `MotionsOptions`.
*/
public convenience init(target targetObject: NSObject, duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = .none) {
public convenience init(target targetObject: NSObject, duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = MotionOptions.none) {

self.init(target: targetObject, properties: [], statesForProperties: nil, duration: duration, easing: easing, options: options)
}
Expand All @@ -552,13 +552,13 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
* - easing: An optional `EasingUpdateClosure` easing equation to use when moving the values of the given properties. `EasingLinear.easeNone()` is the default equation if none is provided.
* - options: An optional set of `MotionsOptions`.
*/
public convenience init(target targetObject: NSObject, statesForProperties templateObjects: [PropertyStates], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = .none) {
public convenience init(target targetObject: NSObject, statesForProperties templateObjects: [PropertyStates], duration: TimeInterval, easing: EasingUpdateClosure?=EasingLinear.easeNone(), options: MotionOptions? = MotionOptions.none) {

self.init(target: targetObject, properties: nil, statesForProperties: templateObjects, duration: duration, easing: easing, options: options)
}


private init(target targetObject: NSObject, properties props: [PropertyData]?, statesForProperties: [PropertyStates]?, duration: TimeInterval, easing: EasingUpdateClosure?, options: MotionOptions? = .none) {
private init(target targetObject: NSObject, properties props: [PropertyData]?, statesForProperties: [PropertyStates]?, duration: TimeInterval, easing: EasingUpdateClosure?, options: MotionOptions? = MotionOptions.none) {

var properties = props ?? []

Expand Down Expand Up @@ -781,7 +781,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {

// determine if target property is a value we can update directly, or if it's an element of a struct we need to replace
property.parentKeyPath = property.path
var keys: [String] = property.path.components(separatedBy: ".")
let keys: [String] = property.path.components(separatedBy: ".")
let key_count = keys.count

if (key_count > 1) {
Expand Down Expand Up @@ -1145,7 +1145,7 @@ public class Motion: Moveable, Additive, TempoDriven, PropertyDataDelegate {
let elapsed_time = self.currentTime - startTime

for index in 0 ..< properties.count {
var property = properties[index]
let property = properties[index]

var new_value: Double = 0.0

Expand Down
Loading

0 comments on commit d3c8df5

Please sign in to comment.