MaterialMotionPop 2.1.0

MaterialMotionPop 2.1.0

TestsTested
LangLanguage SwiftSwift
License Apache 2
ReleasedLast Release Feb 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Jeff Verkoeyen.



 
Depends on:
pop~> 1.0
MaterialMotionRuntime< 7.0, >= 4.0
 

  • By
  • The Material Motion Authors

POP for Material Motion (Swift)

The POP Material Motion family provides a bridge between Facebook’s POP library and the Material Motion runtime.

Supported languages

  • Swift 3
  • Objective-C

Features

SpringTo uses POP springs to animate properties using spring physics driven on the main thread of the application.

For example, you might use a SpringTo plan to move a view’s position to a specific position on screen:

let springTo = SpringTo("position", destination: CGPoint(x: 10, y: 10))
scheduler.addPlan(springTo, to: view.layer)

SpringTo supports a subset of key paths on certain types:

CALayer

  • backgroundColor
  • bounds
  • cornerRadius
  • borderWidth
  • borderColor
  • opacity
  • position
  • position.x
  • position.y
  • transform.rotation.z
  • transform.rotation.x
  • transform.rotation.y
  • transform.scale.x
  • transform.scale
  • transform.scale.y
  • bounds.size
  • sublayerTransform.scale
  • sublayerTransform.translation.x
  • sublayerTransform.translation
  • sublayerTransform.translation.y
  • sublayerTransform.translation.z
  • transform.translation.x
  • transform.translation
  • transform.translation.y
  • transform.translation.z
  • zPosition
  • shadowColor
  • shadowOffset
  • shadowOpacity
  • shadowRadius

CAShapeLayer

  • strokeStart
  • strokeEnd
  • strokeColor
  • fillColor
  • lineWidth
  • lineDashPhase

NSLayoutConstraint

  • constant

UIView

  • alpha
  • backgroundColor
  • bounds
  • center
  • frame
  • transform.scale.x
  • transform.scale
  • transform.scale.y
  • bounds.size
  • tintColor

UIScrollView

  • contentOffset
  • contentSize
  • zoomScale
  • contentInset
  • scrollIndicatorInsets

UINavigationBar

  • barTintColor

UILabel

  • textColor

Read the feature request for supporting more key paths.

Installation

Usage

Import the framework:

@import MaterialMotionPop;

You will now have access to all of the APIs.

Example apps/unit tests

Check out a local copy of the repo to access the Catalog application by running the following commands:

git clone https://github.com/material-motion/pop-swift.git
cd pop-swift
pod install
open MaterialMotionPop.xcworkspace

Guides

  1. How to animate a property with a SpringTo plan
  2. How to configure spring behavior
  3. How to pause a spring while a gesture recognizer is active

How to animate a property with a SpringTo plan

Code snippets:

In Objective-C:

MDMSpringTo *springTo = [[MDMSpringTo alloc] initWithProperty:"<#property key path#>"
                                                  destination:<#Destination value#>];
[scheduler addPlan:springTo to:<#Object#>];

In Swift:

let springTo = SpringTo("<#property key path#>", destination: <#Destination value#>)
scheduler.addPlan(springTo, to: <#Object#>)

How to configure spring behavior

A spring’s behavior can be configured by setting a SpringConfiguration object on the SpringTo instance.

Code snippets:

In Objective-C:

springTo.configuration = [[MDMSpringConfiguration alloc] initWithTension:<#tension#>
                                                                friction:<#friction#>];

In Swift:

springTo.configuration = SpringConfiguration(tension: <#tension#>, friction: <#friction#>)

How to pause a spring while a gesture recognizer is active

Code snippets:

In Objective-C:

MDMPauseSpring *pauseSpring = [[MDMPauseSpring alloc] initWithProperty:"<#property key path#>"
                                                     gestureRecognizer:<#gesture recognizer#>];
[scheduler addPlan:springTo to:<#Object#>];

In Swift:

let springTo = MDMPauseSpring("<#property key path#>", whileActive: <#gesture recognizer#>)
scheduler.addPlan(springTo, to: <#Object#>)

Contributing

We welcome contributions!

Check out our upcoming milestones.

Learn more about our team, our community, and our contributor essentials.

License

Licensed under the Apache 2.0 license. See LICENSE for details.