Skip to content

Commit

Permalink
Create public variables for certain elements to allow for customization
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyrea committed May 15, 2016
1 parent 00c3409 commit 7b6850f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions JRLongPressGestureHandler/Source/JRLongPressGestureHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,20 @@ public class JRLongPressGestureHandler {
private var backupIndexPath: NSIndexPath?
private var startIndexPath: NSIndexPath!

public var transformOnCellSelection: CGAffineTransform!
public var transformOnCellDeposit: CGAffineTransform!
public var durationForSelectionAnimation: NSTimeInterval!
public var durationForDepositAnimation: NSTimeInterval!
public var alphaForCell: CGFloat!

public init(delegate: JRLongPressGestureHandlerDelegate) {
self.delegate = delegate

transformOnCellSelection = CGAffineTransformMakeScale(1.05, 1.05)
transformOnCellDeposit = CGAffineTransformIdentity
durationForSelectionAnimation = 0.25
durationForDepositAnimation = 0.25
alphaForCell = 0.98
}

public func longPressGestureRecognized(tableView: UITableView, gesture: UILongPressGestureRecognizer) {
Expand Down Expand Up @@ -81,10 +93,10 @@ public class JRLongPressGestureHandler {
snapshot = customSnapshotFromView(cell, snapshotCenter: centerPoint)
tableView.addSubview(snapshot!)

UIView.animateWithDuration(0.25, animations: { () -> Void in
UIView.animateWithDuration(durationForSelectionAnimation, animations: { () -> Void in
centerPoint.y = location.y
cell.alpha = CellAlpha.Hidden.rawValue
self.configureLocalSnapshot(centerPoint, transform: CGAffineTransformMakeScale(1.05, 1.05), alpha: 0.98)
self.configureLocalSnapshot(centerPoint, transform: self.transformOnCellSelection, alpha: self.alphaForCell)
})
}

Expand All @@ -97,8 +109,8 @@ public class JRLongPressGestureHandler {
private func depositCellAnimation(tableView: UITableView, indexPath: NSIndexPath) {
let cell = tableView.cellForRowAtIndexPath(indexPath)!
cell.alpha = CellAlpha.Hidden.rawValue
UIView.animateWithDuration(0.25, animations: { () -> Void in
self.configureLocalSnapshot(cell.center, transform: CGAffineTransformIdentity, alpha: 0.0)
UIView.animateWithDuration(durationForDepositAnimation, animations: { () -> Void in
self.configureLocalSnapshot(cell.center, transform: self.transformOnCellDeposit, alpha: 0.0)
cell.alpha = CellAlpha.Visible.rawValue

}, completion: { (finished) in
Expand Down

0 comments on commit 7b6850f

Please sign in to comment.