Skip to content

Commit

Permalink
Add clockwise rotation property
Browse files Browse the repository at this point in the history
  • Loading branch information
BalestraPatrick committed May 24, 2016
1 parent 911f115 commit 48d8dc6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions Example/ParticlesLoadingView/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ViewController: UIViewController {
view.particleEffect = .Laser
view.duration = 1.5
view.particlesSize = 15.0
view.clockwiseRotation = true
view.layer.borderColor = UIColor.lightGrayColor().CGColor
view.layer.borderWidth = 1.0
view.layer.cornerRadius = 15.0
Expand Down
3 changes: 3 additions & 0 deletions Pod/Classes/ParticlesLoadingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public class ParticlesLoadingView: UIView {
}
}

/// Default value is false so the animation is counter-clockwise. Set this property to true to make the animation go clockwise.
public var clockwiseRotation: Bool = false

/// SKScene subclass that is responsible for the emission of particles.
private var scene: ParticlesScene!

Expand Down
7 changes: 6 additions & 1 deletion Pod/Classes/ParticlesScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ public class ParticlesScene: SKScene {
let verticalTranslationFactor = 2 / (1 - verticalInsetScaleFactor)
border.applyTransform(CGAffineTransformMakeScale(horizontalInsetScaleFactor, verticalInsetScaleFactor))
border.applyTransform(CGAffineTransformMakeTranslation(scene.frame.size.width / horizontalTranslationFactor, scene.frame.size.height / verticalTranslationFactor))
let followLine = SKAction.followPath(border.CGPath, asOffset: false, orientToPath: true, duration: duration)
var followLine = SKAction.followPath(border.CGPath, asOffset: false, orientToPath: true, duration: duration)
if let superview = view?.superview as? ParticlesLoadingView {
if superview.clockwiseRotation {
followLine = followLine.reversedAction()
}
}
loopAction = SKAction.repeatActionForever(followLine)
}
}
Expand Down

0 comments on commit 48d8dc6

Please sign in to comment.