Skip to content

Commit a4d2608

Browse files
committed
Add panMultiplier
1 parent 334d3a1 commit a4d2608

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

TVOSSlideViewController/SupportingFiles/Base.lproj/Main.storyboard

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
<userDefinedRuntimeAttributes>
7070
<userDefinedRuntimeAttribute type="boolean" keyPath="shrinks" value="YES"/>
7171
<userDefinedRuntimeAttribute type="boolean" keyPath="parallax" value="YES"/>
72+
<userDefinedRuntimeAttribute type="number" keyPath="panMultiplier">
73+
<real key="value" value="0.5"/>
74+
</userDefinedRuntimeAttribute>
7275
</userDefinedRuntimeAttributes>
7376
<connections>
7477
<outlet property="leftView" destination="ACm-Ng-4aj" id="Nxa-oY-aC9"/>

TVOSSlideViewController/TVOSSlideViewController/TVOSSlideViewController.swift

+11-7
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public class TVOSSlideViewController: UIViewController {
7676
@IBInspectable public var rightTrashold: CGFloat = 0.1
7777
@IBInspectable public var leftTrashold: CGFloat = 0.1
7878

79+
// for smoothing pan gesture update speed
80+
@IBInspectable public var panMultiplier: CGFloat = 1
81+
7982
// animate contentView autolayout enabled or not
8083
@IBInspectable public var shrinks: Bool = false
8184

@@ -340,21 +343,22 @@ public class TVOSSlideViewController: UIViewController {
340343
internal func panGestureDidChange(pan: UIPanGestureRecognizer) {
341344
if pan == panGestureRecognizer {
342345
let translation = pan.translationInView(view)
346+
let value = translation.x * panMultiplier
343347

344348
switch type {
345349
case .LeftRightDrawer:
346-
if translation.x > 0 {
347-
updateLeftDrawer(translation.x, state: pan.state)
350+
if value > 0 {
351+
updateLeftDrawer(value, state: pan.state)
348352
} else {
349-
updateRightDrawer(translation.x, state: pan.state)
353+
updateRightDrawer(value, state: pan.state)
350354
}
351355
case .LeftDrawer:
352-
if translation.x > 0 {
353-
updateLeftDrawer(translation.x, state: pan.state)
356+
if value > 0 {
357+
updateLeftDrawer(value, state: pan.state)
354358
}
355359
case .RightDrawer:
356-
if translation.x < 0 {
357-
updateRightDrawer(translation.x, state: pan.state)
360+
if value < 0 {
361+
updateRightDrawer(value, state: pan.state)
358362
}
359363
case .NoDrawer:
360364
break

0 commit comments

Comments
 (0)