Skip to content

Commit

Permalink
Add initial README.md content.
Browse files Browse the repository at this point in the history
Summary: Closes #1

Reviewers: markwei, O2 Material Motion, appsforartists

Reviewed By: markwei, O2 Material Motion, appsforartists

Subscribers: appsforartists

Tags: #material_motion

Differential Revision: http://codereview.cc/D1839
  • Loading branch information
jverkoey committed Nov 2, 2016
1 parent b4418fa commit ae9b29e
Showing 1 changed file with 80 additions and 4 deletions.
84 changes: 80 additions & 4 deletions README.md
Expand Up @@ -3,6 +3,36 @@
[![Build Status](https://travis-ci.org/material-motion/material-motion-family-direct-manipulation-swift.svg?branch=develop)](https://travis-ci.org/material-motion/material-motion-family-direct-manipulation-swift)
[![codecov](https://codecov.io/gh/material-motion/material-motion-family-direct-manipulation-swift/branch/develop/graph/badge.svg)](https://codecov.io/gh/material-motion/material-motion-family-direct-manipulation-swift)

## Supported languages

- Swift 3
- Objective-C

## Features

This library consists of the following plans:

- `Draggable`, `Pinchable`, and `Rotatable`
- `DirectlyManipulable`
- `ChangeAnchorPoint`

The `Draggable`, `Pinchable`, and `Rotatable` plans allow a user to move, scale, and rotate a view.
They each listen for deltas emitted by a gesture recognizer and add them to the target.

If a view can be dragged then it can often be pinched and rotated too. To make this easy, we provide
a `DirectlyManipulable` plan. It's equivalent to individually adding `Draggable`, `Pinchable`, and
`Rotatable` to the same target.

The collection of `Draggable`, `Pinchable`, `Rotatable`, and `DirectlyManipulable` represent traits
that can describe behavior of a target view. When any of these traits are added to a view the view's
`isUserInteractionEnabled` is enabled. If the plan's associated gesture recognizer is not yet
associated with a view then the gesture recognizer will be added to the target view.

`ChangeAnchorPoint` adjusts `view.layer.anchorPoint` while maintaining the same `view.frame`. In
practice you will not use this plan directly because `Draggable`, `Pinchable`, and `Rotatable` each
provide the `shouldAdjustAnchorPointOnGestureStart` property for automatically emitting a
ChangeAnchorPoint instance.

## Installation

### Installation with CocoaPods
Expand Down Expand Up @@ -42,12 +72,58 @@ commands:

## Guides

1. [Architecture](#architecture)
2. [How to ...](#how-to-...)
1. [How to make a view directly manipulable](#how-to-make-a-view-directly-manipulable)
2. [How to make a view draggable](#how-to-make-a-view-draggable)
3. [How to use an existing gesture recognizer to make a view draggable](#how-to-use-an-existing-gesture-recognizer-to-make-a-view-draggable)

### How to make a view directly manipulable

Code snippets:

***In Objective-C:***

```objc
[runtime addPlan:[MDMDirectlyManipulable new] to:<#Object#>];
```
***In Swift:***
```swift
runtime.addPlan(DirectlyManipulable(), to: <#Object#>)
```

### How to make a view draggable

Code snippets:

***In Objective-C:***

```objc
[runtime addPlan:[MDMDraggable new] to:<#Object#>];
```
***In Swift:***
```swift
runtime.addPlan(Draggable(), to: <#Object#>)
```

### How to use an existing gesture recognizer to make a view draggable

Code snippets:

***In Objective-C:***

```objc
MDMDraggable *draggable = [[MDMDraggable alloc] initWithGestureRecognizer:panGestureRecognizer];
[runtime addPlan:draggable to:<#Object#>];
```
### Architecture
***In Swift:***
### How to ...
```swift
runtime.addPlan(Draggable(withGestureRecognizer: panGestureRecognizer), to: <#Object#>)
```

## Contributing

Expand Down

0 comments on commit ae9b29e

Please sign in to comment.