diff --git a/.jazzy.yaml b/.jazzy.yaml new file mode 100644 index 0000000..fb3f97d --- /dev/null +++ b/.jazzy.yaml @@ -0,0 +1,8 @@ +module: MotionInterchange +module_version: 1.4.0 +sdk: iphonesimulator +umbrella_header: src/MotionInterchange.h +objc: true +github_url: https://github.com/material-motion/motion-interchange-objc +github_file_prefix: https://github.com/material-motion/motion-interchange-objc/tree/v1.4.0 + diff --git a/BUILD b/BUILD index 30ee3e5..1b38655 100644 --- a/BUILD +++ b/BUILD @@ -33,6 +33,11 @@ strict_warnings_objc_library( "src/*.h", "src/private/*.h", ]), + sdk_frameworks = [ + "CoreGraphics", + "Foundation", + "QuartzCore", + ], enable_modules = 1, includes = ["src"], visibility = ["//visibility:public"], diff --git a/CHANGELOG.md b/CHANGELOG.md index bc8ed4d..b7357ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,31 @@ +# 1.4.0 + +This minor release introduces new APIs for creating springs that have an initial velocity. + +## New features + +Added new APIs for creating springs with initial velocity: +`MDMMotionCurveMakeSpringWithInitialVelocity` and `_MDMSpringWithInitialVelocity`. + +## Source changes + +* [Add new APIs for creating springs with initial velocity. (#19)](https://github.com/material-motion/motion-interchange-objc/commit/326180f9f5f99e7d5e9e23131de8c24abe2e1dbf) (featherless) + +## API changes + +### MDMMotionCurveMakeSpringWithInitialVelocity + +**new** function: `MDMMotionCurveMakeSpringWithInitialVelocity` + +### _MDMSpringWithInitialVelocity + +**new** macro: `_MDMSpringWithInitialVelocity` + +## Non-source changes + +* [Add sdk_frameworks dependencies to the BUILD file. (#18)](https://github.com/material-motion/motion-interchange-objc/commit/a601fb65166426bc708d84c0e29d89913c445d04) (featherless) +* [Add jazzy yaml.](https://github.com/material-motion/motion-interchange-objc/commit/130e9760bbb8c0e2179f820cc14f1278c9465b84) (Jeff Verkoeyen) + # 1.3.0 This minor releases introduces new APIs for defining motion curves. diff --git a/MotionInterchange.podspec b/MotionInterchange.podspec index ff98c90..b22cd8f 100644 --- a/MotionInterchange.podspec +++ b/MotionInterchange.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "MotionInterchange" s.summary = "Motion interchange format." - s.version = "1.3.0" + s.version = "1.4.0" s.authors = "The Material Motion Authors" s.license = "Apache 2.0" s.homepage = "https://github.com/material-motion/motion-interchange-objc" diff --git a/Podfile.lock b/Podfile.lock index 99c3b47..a5f15b2 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,6 +1,6 @@ PODS: - CatalogByConvention (2.1.1) - - MotionInterchange (1.3.0) + - MotionInterchange (1.4.0) DEPENDENCIES: - CatalogByConvention @@ -12,7 +12,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: CatalogByConvention: c3a5319de04250a7cd4649127fcfca5fe3322a43 - MotionInterchange: 988fc0011e4b806cc33f2fb4f9566f5eeb4159e8 + MotionInterchange: 35e0fd286ceab53dd4ee03494b3fcafa6a70637a PODFILE CHECKSUM: 09090d12db5aab00a13fe82da94f338ebd03f5dc diff --git a/src/MDMMotionCurve.h b/src/MDMMotionCurve.h index 4aab196..dedeb85 100644 --- a/src/MDMMotionCurve.h +++ b/src/MDMMotionCurve.h @@ -94,6 +94,21 @@ FOUNDATION_EXTERN MDMMotionCurve MDMMotionCurveMakeSpring(float mass, float tens NS_SWIFT_NAME(MotionCurveMakeSpring(mass:tension:friction:)); // clang-format on +/** + Creates a spring curve with the provided configuration. + + Tension and friction map to Core Animation's stiffness and damping, respectively. + + See the documentation for CASpringAnimation for more information. + */ +// clang-format off +FOUNDATION_EXTERN MDMMotionCurve MDMMotionCurveMakeSpringWithInitialVelocity(float mass, + float tension, + float friction, + float initialVelocity) + NS_SWIFT_NAME(MotionCurveMakeSpring(mass:tension:friction:initialVelocity:)); +// clang-format on + /** For cubic bezier curves, returns a reversed cubic bezier curve. For all other curve types, a copy of the original curve is returned. @@ -136,21 +151,30 @@ typedef NS_ENUM(NSUInteger, MDMSpringMotionCurveDataIndex) { // Objective-C-specific macros #define _MDMBezier(p1x, p1y, p2x, p2y) \ - (MDMMotionCurve) { \ + ((MDMMotionCurve) { \ .type = MDMMotionCurveTypeBezier, \ .data = { p1x, \ p1y, \ p2x, \ p2y } \ - } + }) #define _MDMSpring(mass, tension, friction) \ - (MDMMotionCurve) { \ + ((MDMMotionCurve) { \ .type = MDMMotionCurveTypeSpring, \ .data = { mass, \ tension, \ friction } \ - } + }) + +#define _MDMSpringWithInitialVelocity(mass, tension, friction, initialVelocity) \ + ((MDMMotionCurve) { \ + .type = MDMMotionCurveTypeSpring, \ + .data = { mass, \ + tension, \ + friction, \ + initialVelocity } \ + }) /** A linear bezier motion curve. diff --git a/src/MDMMotionCurve.m b/src/MDMMotionCurve.m index 7cb7b3c..828d100 100644 --- a/src/MDMMotionCurve.m +++ b/src/MDMMotionCurve.m @@ -21,7 +21,14 @@ MDMMotionCurve MDMMotionCurveMakeBezier(float p1x, float p1y, float p2x, float p } MDMMotionCurve MDMMotionCurveMakeSpring(float mass, float tension, float friction) { - return _MDMSpring(mass, tension, friction); + return MDMMotionCurveMakeSpringWithInitialVelocity(mass, tension, friction, 0); +} + +MDMMotionCurve MDMMotionCurveMakeSpringWithInitialVelocity(float mass, + float tension, + float friction, + float initialVelocity) { + return _MDMSpringWithInitialVelocity(mass, tension, friction, initialVelocity); } MDMMotionCurve MDMMotionCurveFromTimingFunction(CAMediaTimingFunction *timingFunction) {