Skip to content

Make rotating of cards customizable #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ZLSwipeableViewSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ZLSwipeableViewSwift"
s.version = "0.0.7"
s.version = "0.0.8"
s.summary = "A simple view for building card like interface like Tinder and Potluck."
s.description = <<-DESC
ZLSwipeableViewSwift is a simple view for building card like interface like Tinder and Potluck.
Expand All @@ -11,9 +11,9 @@ Pod::Spec.new do |s|
s.author = { "Zhixuan Lai" => "[email protected]" }
s.social_media_url = "http://twitter.com/ZhixuanLai"

s.platform = :ios, "8.0"
s.platform = :ios, "9.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason this change to drop support for iOS 8?


s.source = { :git => "https://github.com/zhxnlai/ZLSwipeableViewSwift.git", :tag => "0.0.7" }
s.source = { :git => "https://github.com/zhxnlai/ZLSwipeableViewSwift.git", :tag => "0.0.8" }
s.source_files = "ZLSwipeableViewSwift/*.swift"

s.framework = "UIKit"
Expand Down
18 changes: 11 additions & 7 deletions ZLSwipeableViewSwift/ViewManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,18 @@ class ViewManager : NSObject {
private let containerView: UIView
private let miscContainerView: UIView
private let animator: UIDynamicAnimator
private let rotatingSpeedMultiplyer: CGFloat
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be rotatingSpeedMultiplier


private weak var swipeableView: ZLSwipeableView?

init(view: UIView, containerView: UIView, index: Int, miscContainerView: UIView, animator: UIDynamicAnimator, swipeableView: ZLSwipeableView) {
init(view: UIView, containerView: UIView, index: Int, miscContainerView: UIView, animator: UIDynamicAnimator, swipeableView: ZLSwipeableView, rotatingSpeedMultiplyer rotMul: CGFloat) {
self.view = view
self.containerView = containerView
self.miscContainerView = miscContainerView
self.animator = animator
self.swipeableView = swipeableView
self.state = ViewManager.defaultSnappingState(view)
self.rotatingSpeedMultiplyer = rotMul
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well, Multiplyer should be spelt Multiplier 👍

Copy link
Collaborator

@AndrewSB AndrewSB Sep 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and anywhere else in the file where you've used or defined a variable with that in it's name


super.init()

Expand Down Expand Up @@ -160,13 +163,14 @@ class ViewManager : NSObject {

private func attachView(toPoint point: CGPoint) {
anchorView.center = point
anchorView.backgroundColor = UIColor.blueColor()
anchorView.hidden = true


// attach aView to anchorView
let p = view.center
viewToAnchorViewAttachmentBehavior = UIAttachmentBehavior(item: view, offsetFromCenter: UIOffset(horizontal: -(p.x - point.x), vertical: -(p.y - point.y)), attachedToItem: anchorView, offsetFromCenter: UIOffsetZero)
viewToAnchorViewAttachmentBehavior!.length = 0
let x = (point.x - p.x) * rotatingSpeedMultiplyer + p.x
let y = (point.y - p.y) * rotatingSpeedMultiplyer + p.y
let newPoint = CGPoint(x: x, y: y)

viewToAnchorViewAttachmentBehavior = UIAttachmentBehavior.pinAttachmentWithItem(view, attachedToItem: anchorView, attachmentAnchor: newPoint)

// attach anchorView to point
anchorViewToPointAttachmentBehavior = UIAttachmentBehavior(item: anchorView, offsetFromCenter: UIOffsetZero, attachedToAnchor: point)
Expand Down Expand Up @@ -211,4 +215,4 @@ class ViewManager : NSObject {
animator.removeBehavior(behavior)
}

}
}
9 changes: 5 additions & 4 deletions ZLSwipeableViewSwift/ZLSwipeableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class ZLSwipeableView: UIView {
public var shouldSwipeView = ZLSwipeableView.defaultShouldSwipeViewHandler()
public var minTranslationInPercent = CGFloat(0.25)
public var minVelocityInPointPerSecond = CGFloat(750)
public var rotatingSpeedMultiplyer = CGFloat(1)
public var allowedDirection = Direction.Horizontal
public var onlySwipeTopCard = false

Expand Down Expand Up @@ -185,7 +186,7 @@ public class ZLSwipeableView: UIView {
return
}

let viewManager = ViewManager(view: view, containerView: containerView, index: index, miscContainerView: miscContainerView, animator: animator, swipeableView: self)
let viewManager = ViewManager(view: view, containerView: containerView, index: index, miscContainerView: miscContainerView, animator: animator, swipeableView: self, rotatingSpeedMultiplyer: rotatingSpeedMultiplyer)
viewManagers[view] = viewManager
}

Expand Down Expand Up @@ -382,7 +383,7 @@ public func *(lhs: CGPoint, rhs: CGFloat) -> CGPoint {
return CGPoint(x: lhs.x * rhs, y: lhs.y * rhs)
}

extension CGPoint {
public extension CGPoint {

init(vector: CGVector) {
self.init(x: vector.dx, y: vector.dy)
Expand All @@ -407,15 +408,15 @@ extension CGPoint {

}

extension CGVector {
public extension CGVector {

init(point: CGPoint) {
self.init(dx: point.x, dy: point.y)
}

}

extension Array where Element: Equatable {
public extension Array where Element: Equatable {

func arrayByRemoveObjectsInArray(array: [Element]) -> [Element] {
return Array(self).filter() { element in !array.contains(element) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Andrew Breckenridge";
TargetAttributes = {
460B72501B76D3E600BB5ED8 = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 0800;
};
};
};
Expand Down Expand Up @@ -162,8 +163,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -186,7 +189,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -210,8 +213,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -228,9 +233,10 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -242,34 +248,40 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = tfw.ZLSwipeableViewSwift;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 2.3;
};
name = Debug;
};
460B725B1B76D3E600BB5ED8 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = tfw.ZLSwipeableViewSwift;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 2.3;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down