VLCHorizontalSwipeGestureRecognizer.m 944 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // VLCHorizontalSwipeGestureRecognizer.m
  3. // VLC for iOS
  4. //
  5. // Created by Felix Paul Kühne on 26.05.13.
  6. // Copyright (c) 2013 VideoLAN. All rights reserved.
  7. //
  8. // Refer to the COPYING file of the official project for license.
  9. //
  10. #import "VLCHorizontalSwipeGestureRecognizer.h"
  11. @interface VLCHorizontalSwipeGestureRecognizer ()
  12. {
  13. CGFloat _xOrigin;
  14. }
  15. @end
  16. @implementation VLCHorizontalSwipeGestureRecognizer
  17. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  18. {
  19. _xOrigin = [touches.anyObject locationInView:self.view].x;
  20. }
  21. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
  22. {
  23. CGFloat currentX = [touches.anyObject locationInView:self.view].x;
  24. CGFloat viewWidth = self.view.bounds.size.width;
  25. if ([self.delegate respondsToSelector:@selector(horizontalSwipePercentage:inView:)])
  26. [self.delegate horizontalSwipePercentage:(currentX - _xOrigin)/viewWidth inView:self.view];
  27. }
  28. @end