• This repository has been archived on 14/Aug/2021
  • Stars
    star
    1,419
  • Rank 33,151 (Top 0.7 %)
  • Language
    Swift
  • License
    Apache License 2.0
  • Created almost 8 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A toolkit for building responsive motion using Core Animation.

Material Motion

Reactive motion driven by Core Animation.

Swift 3.1.x iOS 9.0+ Build Status codecov CocoaPods Compatible Platform Docs Chat

This library includes a variety of ready-to-use interactions. Interactions are registered to an instance of MotionRuntime:

// Store me for as long as the interactions should take effect.
let runtime = MotionRuntime(containerView: <#view#>)
InteractionSnippet
ArcMove
let arcMove = ArcMove()
arcMove.from.value = <#from#>
arcMove.to.value = <#to#>
runtime.add(arcMove, to: <#view#>)
ChangeDirection
runtime.add(ChangeDirection(withVelocityOf: gesture),
            to: <#direction#>)
DirectlyManipulable
runtime.add(DirectlyManipulable(), to: <#view#>)
Draggable
runtime.add(Draggable(), to: <#view#>)
Rotatable
runtime.add(Rotatable(), to: <#view#>)
Scalable
runtime.add(Scalable(), to: <#view#>)
SetPositionOnTap
runtime.add(SetPositionOnTap(),
            to: runtime.get(<#view#>.layer).position)
Spring
let spring = Spring()
spring.destination.value = <#initial destination#>
runtime.add(spring, to: <#view#>)
Tossable
let tossable = Tossable()
tossable.spring.destination.value = <#initial destination#>
runtime.add(tossable, to: <#view#>)
Tween
runtime.add(Tween(duration: 0.5, values: [1, 0]),
            to: runtime.get(<#view#>.layer).opacity)

Installation

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C and Swift libraries. CocoaPods automates the process of using third-party libraries in your projects. See the Getting Started guide for more information. You can install it with the following command:

gem install cocoapods

Add MaterialMotion to your Podfile:

pod 'MaterialMotion'

You will need to add use_frameworks! to your Podfile in order use Material Motion in your swift app.

A simple Podfile might look like so:

project 'MyApp/MyApp.xcodeproj'

use_frameworks!

target 'MyApp' do
  pod 'MaterialMotion'
end

Then run the following command:

pod install

Usage

Import the framework:

import MaterialMotion

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/material-motion-swift.git
cd material-motion-swift
pod install
open MaterialMotion.xcworkspace

Case studies

Carousel

A carousel with pages that scale in and fade out in reaction to their scroll position.

View the source.

Contextual transition

A contextual view can be used to create continuity during transitions between view controllers. In this case study the selected photo is the contextual view. It's possible to flick the view to dismiss it using the tossable interaction.

Makes use of: Draggable, Tossable, Transition, TransitionSpring, Tween.

View the source.

Floating action button transition

A floating action button transition is a type of contextual transition that animates a mask outward from a floating button.

Makes use of: Transition and Tween.

View the source.

Material expansion

A Material Design transition using asymetric transformations.

Makes use of: Tween.

View the source.

Modal dialog

A modal dialog that's presented over the existing context and is dismissable using gestures.

Makes use of: Tossable and TransitionSpring.

View the source.

Pull down to dismiss

A modal scroll view controller that can be dismissed with a drag gesture.

Makes use of: Tossable and TransitionSpring.

View the source.

Sticker picker

Each sticker is individually directly manipulable, meaning they can be dragged, rotated, and scaled using multitouch gestures.

Makes use of: DirectlyManipulable.

View the source.

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.

More Repositories

1

direct

Direct is a tool that helps motion designers provide clear, precise motion direction for engineers.
TypeScript
462
star
2

material-motion-android

Reactive motion for Android. Deprecated; please use the Motion library in Material Components for Android instead: https://material.io/develop/android/theming/motion/.
Java
445
star
3

material-motion-js

Reusable gestural interactions in JavaScript. In development.
TypeScript
289
star
4

apidiff

Generate API diffs as markdown for Objective-C, Swift, and Android libraries.
Swift
116
star
5

indefinite-observable-js

An Observable for JavaScript that never calls complete or error
JavaScript
68
star
6

motion-animator-objc

A Motion Animator creates performant, interruptible iOS animations from motion specs.
Objective-C
54
star
7

material-motion

Starmap and team docs
JavaScript
49
star
8

motion-transitioning-objc

Light-weight API for building UIViewController transitions.
Objective-C
28
star
9

physics-android

Java
28
star
10

motion-interchange-objc

A standard format for representing animation traits in Objective-C and Swift.
Objective-C
18
star
11

gestures-android

Gesture recognizers for Android
Java
18
star
12

material-motion-rebound-android

Java
17
star
13

indefinite-observable-swift

A generic Observable for Swift
Swift
8
star
14

tools

The Material Motion team's tools
Shell
7
star
15

indefinite-observable-android

An Observable for Android that never calls complete or error
Java
3
star
16

sublime

Sublime Package to support Material Motion development
Python
3
star
17

conventions-android

A convention for Android libraries.
3
star
18

material-motion-components-swift

Swift
2
star
19

material-motion-pop-swift

1
star
20

gesture-principles

1
star
21

milemarker

Organization-wide dashboard
JavaScript
1
star