VLCVerticalSwipeGestureRecognizer.m 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //
  2. // VLCVerticalSwipeGestureRecognizer.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 "VLCVerticalSwipeGestureRecognizer.h"
  11. @interface VLCVerticalSwipeGestureRecognizer ()
  12. {
  13. CGFloat _yOrigin;
  14. }
  15. @end
  16. @implementation VLCVerticalSwipeGestureRecognizer
  17. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  18. {
  19. _yOrigin = [touches.anyObject locationInView:self.view].y;
  20. }
  21. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
  22. {
  23. CGPoint locationInView = [touches.anyObject locationInView:self.view];
  24. CGFloat currentY = locationInView.y;
  25. CGFloat currentX = locationInView.x;
  26. CGSize viewSize = self.view.bounds.size;
  27. if ([self.delegate respondsToSelector:@selector(verticalSwipePercentage:inView:half:)])
  28. [self.delegate verticalSwipePercentage:(currentY - _yOrigin)/viewSize.height inView:self.view half:(currentX < (viewSize.width/2)) ? 0 : 1];
  29. }
  30. @end