Skip to content
This repository has been archived by the owner on Jul 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #17 from ejeinc/separate-setNeedsResetRotation
Browse files Browse the repository at this point in the history
`setNeedsResetRotation` is not animated as default
  • Loading branch information
junpluse authored Apr 25, 2017
2 parents 2e5edc6 + 880844c commit 1267fe3
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Examples/MonoImage/Sources/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class ViewController: UIViewController {
#else
let panoramaView = PanoramaView(frame: view.bounds) // iOS Simulator
#endif
panoramaView.setNeedsResetRotation(animated: false)
panoramaView.setNeedsResetRotation()
panoramaView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(panoramaView)

Expand All @@ -40,7 +40,7 @@ final class ViewController: UIViewController {
NSLayoutConstraint.activate(constraints)

// double tap to reset rotation
let doubleTapGestureRecognizer = UITapGestureRecognizer(target: panoramaView, action: #selector(PanoramaView.setNeedsResetRotation))
let doubleTapGestureRecognizer = UITapGestureRecognizer(target: panoramaView, action: #selector(PanoramaView.setNeedsResetRotation(_:)))
doubleTapGestureRecognizer.numberOfTapsRequired = 2
panoramaView.addGestureRecognizer(doubleTapGestureRecognizer)

Expand Down
4 changes: 2 additions & 2 deletions Examples/MonoVideo/Sources/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class ViewController: UIViewController {

private func loadPanoramaView() {
let panoramaView = PanoramaView(frame: view.bounds, device: device)
panoramaView.setNeedsResetRotation(animated: false)
panoramaView.setNeedsResetRotation()
panoramaView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(panoramaView)

Expand All @@ -47,7 +47,7 @@ final class ViewController: UIViewController {
NSLayoutConstraint.activate(constraints)

// double tap to reset rotation
let doubleTapGestureRecognizer = UITapGestureRecognizer(target: panoramaView, action: #selector(PanoramaView.setNeedsResetRotation))
let doubleTapGestureRecognizer = UITapGestureRecognizer(target: panoramaView, action: #selector(PanoramaView.setNeedsResetRotation(_:)))
doubleTapGestureRecognizer.numberOfTapsRequired = 2
panoramaView.addGestureRecognizer(doubleTapGestureRecognizer)

Expand Down
4 changes: 2 additions & 2 deletions Examples/StereoImage/Sources/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class ViewController: UIViewController {

private func loadPanoramaView() {
let panoramaView = PanoramaView(frame: view.bounds, device: device)
panoramaView.setNeedsResetRotation(animated: false)
panoramaView.setNeedsResetRotation()
panoramaView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(panoramaView)

Expand All @@ -36,7 +36,7 @@ final class ViewController: UIViewController {
NSLayoutConstraint.activate(constraints)

// double tap to reset rotation
let doubleTapGestureRecognizer = UITapGestureRecognizer(target: panoramaView, action: #selector(PanoramaView.setNeedsResetRotation))
let doubleTapGestureRecognizer = UITapGestureRecognizer(target: panoramaView, action: #selector(PanoramaView.setNeedsResetRotation(_:)))
doubleTapGestureRecognizer.numberOfTapsRequired = 2
panoramaView.addGestureRecognizer(doubleTapGestureRecognizer)

Expand Down
4 changes: 2 additions & 2 deletions Examples/StereoVideo/Sources/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class ViewController: UIViewController {

private func loadPanoramaView() {
let panoramaView = PanoramaView(frame: view.bounds, device: device)
panoramaView.setNeedsResetRotation(animated: false)
panoramaView.setNeedsResetRotation()
panoramaView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(panoramaView)

Expand All @@ -47,7 +47,7 @@ final class ViewController: UIViewController {
NSLayoutConstraint.activate(constraints)

// double tap to reset rotation
let doubleTapGestureRecognizer = UITapGestureRecognizer(target: panoramaView, action: #selector(PanoramaView.setNeedsResetRotation))
let doubleTapGestureRecognizer = UITapGestureRecognizer(target: panoramaView, action: #selector(PanoramaView.setNeedsResetRotation(_:)))
doubleTapGestureRecognizer.numberOfTapsRequired = 2
panoramaView.addGestureRecognizer(doubleTapGestureRecognizer)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ let panoramaView: PanoramaView = ...
// double tap to re-center the scene
let recognizer = UITapGestureRecognizer(
target: panoramaView,
action: #selector(PanoramaView.setNeedsResetRotation))
action: #selector(PanoramaView.setNeedsResetRotation(_:)))
recognizer.numberOfTapsRequired = 2

panoramaView.addGestureRecognizer(recognizer)
Expand Down
6 changes: 3 additions & 3 deletions Sources/Deprecations+Removals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import SceneKit

extension PanoramaView {
@available(*, deprecated, message: "Use `setNeedsResetRotation()` instead")
@available(*, deprecated, message: "Use `setNeedsResetRotation` instead")
public func resetCenter() {
setNeedsResetRotation()
setNeedsResetRotation(animated: true)
}
}

extension StereoView {
@available(*, deprecated, message: "Use `setNeedsResetRotation()` instead")
@available(*, deprecated, message: "Use `setNeedsResetRotation` instead")
public func resetCenter() {
setNeedsResetRotation()
}
Expand Down
7 changes: 5 additions & 2 deletions Sources/PanoramaView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,14 @@ extension PanoramaView {
interfaceOrientationUpdater.updateInterfaceOrientation(with: transitionCoordinator)
}

public func setNeedsResetRotation(animated: Bool = true) {
public func setNeedsResetRotation(animated: Bool = false) {
panGestureManager.stopAnimations()

orientationNode.setNeedsResetRotation(animated: animated)
}

public func setNeedsResetRotation(_ sender: Any?) {
setNeedsResetRotation(animated: true)
}
}

extension PanoramaView: OrientationIndicatorDataSource {
Expand Down

0 comments on commit 1267fe3

Please sign in to comment.