on master help sign in
Add autorepeat for pan gesture
commit8789187aacfbe754523d00fad1adb3bb0c82a88f authorGunay Mert Karadogan <mertkaradogan@gmail.com> dateFri 10 Jul 2015, 12:42 (11 years ago) parent8f3ccfd
1 file changed+6−4
GMStepper/GMStepper.swift+6−4
GMStepper/GMStepper.swift+6−4
@@ -261,6 +261,7 @@ import UIKit
261261 // Increase only once for each pan gesture
262262 if panState != .HitRightEdge {
263263 value += 1
264+ scheduleTimerWithUserInfo(rightButton)
264265 panState = .HitRightEdge
265266 }
266267
@@ -271,6 +272,7 @@ import UIKit
271272
272273 if panState != .HitLeftEdge {
273274 value -= 1
275+ scheduleTimerWithUserInfo(leftButton)
274276 panState = .HitLeftEdge
275277 }
276278
@@ -278,8 +280,7 @@ import UIKit
278280 animateLimitHitForButton(leftButton)
279281 }
280282 } else {
281− leftButton.backgroundColor = buttonsBackgroundColor
282− rightButton.backgroundColor = buttonsBackgroundColor
283+ reset()
283284 }
284285
285286 case .Ended:
@@ -291,6 +292,7 @@ import UIKit
291292
292293 private func reset() {
293294 panState = .Stale
295+ resetTimer()
294296
295297 UIView.animateWithDuration(self.labelSlideDuration, animations: {
296298 self.label.center = self.labelOriginalCenter
@@ -368,6 +370,7 @@ extension GMStepper {
368370
369371}
370372
373+// MARK: Timer
371374extension GMStepper {
372375 func handleTimerFire(timer: NSTimer) {
373376 timerFireCount += 1
@@ -380,7 +383,6 @@ extension GMStepper {
380383 value += 1
381384 }
382385 }
383−// printTimerGaps()
384386 }
385387 }
386388
@@ -388,7 +390,7 @@ extension GMStepper {
388390 timer = NSTimer.scheduledTimerWithTimeInterval(timerInterval, target: self, selector: "handleTimerFire:", userInfo: userInfo, repeats: true)
389391 }
390392
391− func stopTimer() {
393+ func resetTimer() {
392394 if let timer = timer {
393395 timer.invalidate()
394396 self.timer = nil