Skip to content

Commit

Permalink
Add defaults to translation methods
Browse files Browse the repository at this point in the history
  • Loading branch information
intrepidmatt committed May 10, 2016
1 parent d46f72b commit 4c8fdd3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Pod/Classes/AnimationSugar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ extension UIView {
- Parameter tx: Translation distance along the x axis
- Parameter ty: Translation distance along the y axis
*/
func translate(tx tx: CGFloat, ty: CGFloat) {
func translate(tx tx: CGFloat = 0, ty: CGFloat = 0) {
self.transform = CGAffineTransformTranslate(self.transform, tx, ty)
}

Expand Down Expand Up @@ -208,7 +208,7 @@ extension UIView {
- Parameter tx: Translation distance along the x axis
- Parameter ty: Translation distance along the y axis
*/
func translateFrame(tx tx: CGFloat, ty: CGFloat) {
func translateFrame(tx tx: CGFloat = 0, ty: CGFloat = 0) {
var frame = self.frame
frame.origin.x = frame.origin.x + tx
frame.origin.y = frame.origin.y + ty
Expand Down Expand Up @@ -286,7 +286,7 @@ extension UIView {
- Parameter duration: The duration of the animation
- Returns An `Animation` that can be chained or altered.
*/
func fadeOut(duration duration: NSTimeInterval = Animation.Constants.DefaultAnimationDuration) -> Animation {
func fadeOut(duration duration: NSTimeInterval = Animation.defaultAnimationDuration) -> Animation {
return animate(duration: duration) {
self.alpha = 0.0
}
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@ It was built at [Intrepid](http://intrepid.io).
##Examples

animate {
view.translate(tx: 150, ty: 0)
view.translate(tx: 150)
}

![Image of animation to the right](Images/AnimationSugar_1.gif)

animate {
view.translate(tx: 150, ty: 0)
view.translate(tx: 150)
}
.withSpring(dampingRatio: 0.5, initialVelocity: 0)

![Image of animation with spring](Images/AnimationSugar_2.gif)

animate {
view.translate(tx: 150, ty: 0)
view.translate(tx: 150)
}
.thenAnimate {
view.translate(tx: 0, ty: 150)
view.translate(ty: 150)
}
.thenAnimate {
view.translate(tx: -150, ty: 0)
view.translate(tx: -150)
}
.thenAnimate {
view.translate(tx: 0, yt: -150)
view.translate(ty: -150)
}

![Image of animation in a square](Images/AnimationSugar_3.gif)

animate(duration: 0.3) {
view.translate(tx: 150, ty: 0)
view.translate(tx: 150)
}
.withOption(.CurveEaseOut)
.withCompletion { _ in
Expand Down Expand Up @@ -82,7 +82,7 @@ It was built at [Intrepid](http://intrepid.io).

### UIView helpers

`func translate(tx tx: CGFloat, ty: CGFloat)`
`func translate(tx tx: CGFloat = 0, ty: CGFloat = 0)`

- Translate a view by altering its `transform` property

Expand All @@ -94,7 +94,7 @@ It was built at [Intrepid](http://intrepid.io).

- Rotate a view by altering its `transform` property

`func translateFrame(tx tx: CGFloat, ty: CGFloat)`
`func translateFrame(tx tx: CGFloat = 0, ty: CGFloat = 0)`

- Translate a view by altering its `frame` property

Expand All @@ -118,7 +118,7 @@ It was built at [Intrepid](http://intrepid.io).

- Fade in a view from invisible to visible over time. Can be chained with other animations.

`func fadeOut(duration duration: NSTimeInterval = Animation.Constants.DefaultAnimationDuration) -> Animation`
`func fadeOut(duration duration: NSTimeInterval = Animation.defaultAnimationDuration) -> Animation`

- Fade out a view from visible to invisible over time. Can be chained with other animations.

Expand Down

0 comments on commit 4c8fdd3

Please sign in to comment.