# MotionTransition

## Motion Identifier

Animates the view with a matching motion identifier.

```
.motionIdentifier(_ identifier: String)
```

## Masks To Bounds

Animates the view's current masksToBounds to the given masksToBounds.

```swift
.masksToBounds(_ masksToBounds: Bool)
```

## Background Color

Animates the view's current background color to the given color.

```swift
.background(color: UIColor) -> MotionTransition
```

## Border Color

Animates the view's current border color to the given color.

```swift
.border(color: UIColor)
```

## Border Width

Animates the view's current border width to the given width.

```swift
.border(width: CGFloat)
```

## Corner Radius

Animates the view's current corner radius to the given radius.

```swift
.corner(radius: CGFloat)
```

## Transform

Animates the view's current transform (perspective, scale, rotate) to the given one.

```swift
.transform(_ transform: CATransform3D)
```

## Perspective

Animates the view's current perspective to the given one through a CATransform3D object.

```swift
.perspective(_ perspective: CGFloat)
```

## Rotate

Animates the view's current rotate to the given x, y, and z values.

```swift
.rotate(x: CGFloat, y: CGFloat, z: CGFloat)
```

Animates the view's current rotate to the given point.

```swift
.rotate(_ point: CGPoint, z: CGFloat)
```

Rotate 2d.

```swift
.rotate(_ z: CGFloat)
```

## Scale

Animates the view's current scale to the given x, y, z scale values.

```swift
.scale(x: CGFloat, y: CGFloat, z: CGFloat)
```

Animates the view's current x & y scale to the given scale value.

```swift
.scale(_ xy: CGFloat)
```

Animates the view's current translation to the given x, y, and z values.

```swift
.translate(x: CGFloat, y: CGFloat, z: CGFloat)
```

## Translate

Animates the view's current translation to the given point value (x & y), and a z value.

```swift
.translate(_ point: CGPoint, z: CGFloat)
```

## Position

Animates the view's current position to the given point.

```swift
.position(_ point: CGPoint)
```

## Force Non Fade

Forces the view to not fade during a transition.

```swift
.forceNonFade
```

## Fade In

Fades the view in during a transition.

```swift
.fadeIn
```

## Fade Out

Fades the view out during a transition.

```swift
.fadeOut
```

## Fade

Animates the view's current opacity to the given one.

```swift
.fade(_ opacity: Double)
```

## Z Position

Animates the view's current zPosition to the given position.

```swift
.zPosition(_ position: CGFloat)
```

## Size

Animates the view's current size to the given one.

```swift
.size(_ size: CGSize)
```

## Shadow Path

Animates the view's current shadow path to the given one.

```swift
.shadow(path: CGPath)
```

## Shadow Color

Animates the view's current shadow color to the given one.

```swift
.shadow(color: UIColor)
```

## Shadow Offset

Animates the view's current shadow offset to the given one.

```swift
.shadow(offset: CGSize)
```

## Shadow Opacity

Animates the view's current shadow opacity to the given one.

```swift
.shadow(opacity: Float)
```

## Shadow Radius

Animates the view's current shadow radius to the given one.

```swift
.shadow(radius: CGFloat)
```

## Contents Rect

Animates the view's contents rect to the given one.

```swift
.contents(rect: CGRect)
```

## Contents Scale

Animates the view's contents scale to the given one.

```swift
.contents(scale: CGFloat)
```

## Duration

The duration of the view's animation.

```swift
.duration(_ duration: TimeInterval)
```

## Preferred Duration Matches Longest

Sets the view's animation duration to the longest running animation within a transition.

```swift
.preferredDurationMatchesLongest
```

## Delay

Delays the animation of a given view.

```swift
.delay(_ time: TimeInterval)
```

## Timing Function

Sets the view's timing function for the transition.

```swift
.timingFunction(_ timingFunction: CAMediaTimingFunction)
```

## Spring

Available in iOS 9+, animates a view using the spring API, given a stiffness and damping.

```swift
.spring(stiffness: CGFloat, damping: CGFloat)
```

## Arc

Animates the natural curve of a view. A value of 1 represents a curve in a downward direction, and a value of -1 represents a curve in an upward direction.

```swift
.arc(intensity: CGFloat = 1)
```

## Cascade

Animates subviews with an increasing delay between each animation.

```swift
.cascade(delta: TimeInterval, direction: CascadeDirection, animationDelayedUntilMatchedViews: Bool)
```

## Overlay

Creates an overlay on the animating view with a given color and opacity.

```swift
.overlay(color: UIColor, opacity: CGFloat)
```

## Begin with

Apply transitions directly to the view at the start of the transition. The transitions supplied here won't be animated. For source views, transitions are set directly at the begining of the animation. For destination views, they replace the target state (final appearance).

```swift
.beginWith(transitions: [MotionTransition])
```

## Begin With If Matched

Apply transitions directly to the view at the start of the transition if the view is matched with another view. The transitions supplied here won't be animated. For source views, transitions are set directly at the begining of the animation. For destination views, they replace the target state (final appearance).

```swift
.beginWithIfMatched(transitions: [MotionTransition])
```

## Global Coordinate Space

When using global coordinate space. The view becomes an independent view that is not a subview of any view. It won't move when its parent view moves, and won't be affected by parent view attributes. When a view is matched, this is automatically enabled. The `source` transition will also enable this.

```swift
.useGlobalCoordinateSpace
```

Use same parent coordinate space.

```swift
.useSameParentCoordinateSpace
```

## Ignore Transitions

Ignore all motion transition attributes for a view's direct subviews.

```swift
.ignoreSubviewTransitions
```

Ignore all motion transition attributes for a view's subviews.

```swift
.ignoreSubviewTransitions(recursive: Bool)
```

## Snapshot

This will create a snapshot optimized for different view types. For custom views or views with masking, useOptimizedSnapshot might create snapshots that appear differently than the actual view. In that case, use .useNormalSnapshot or .useSlowRenderSnapshot to disable the optimization.

This transition actually does nothing by itself since .useOptimizedSnapshot is the default.

```swift
.useOptimizedSnapshot
```

Create a snapshot using snapshotView(afterScreenUpdates:).

```swift
.useNormalSnapshot
```

Create a snapshot using layer.render(in: currentContext). This is slower than .useNormalSnapshot but gives more accurate snapshots for some views (eg. UIStackView).

```swift
.useLayerRenderSnapshot
```

Force Motion to not create any snapshots when animating this view. This will mess up the view hierarchy, therefore, view controllers have to rebuild their view structure after the transition finishes.

```swift
.useNoSnapshot
```

## Force Animate

Force the view to animate (Motion will create animation contexts & snapshots for them, so that they can be interactive).

```swift
.forceAnimate
```

## Force Scale Based Size Change

Force Motion to use scale based size animation. This will convert all .size transitions into a `.scale` transition. This is to help Motion animate layers that doesn't support bounds animations. This also gives better performance.

```swift
.useScaleBasedSizeChange
```
