Module: MotionWiretap::Gestures
- Defined in:
- lib/motion-wiretap/ios/wiretap_gestures.rb
Overview
Some gesture recognizer translators. Based on SugarCube’s gesture recognizer methods.
Class Method Summary collapse
- .pan(target, fingers_or_options = nil) {|recognizer| ... } ⇒ Object
- .pinch(target, scale_or_options = nil) {|recognizer| ... } ⇒ Object
- .press(target, duration_or_options = nil) {|recognizer| ... } ⇒ Object
- .rotate(target, rotation_or_options = nil) {|recognizer| ... } ⇒ Object
- .swipe(target, direction_or_options) {|recognizer| ... } ⇒ Object
- .tap(target, taps_or_options = nil) {|recognizer| ... } ⇒ Object
Class Method Details
.tap(taps) ⇒ Object .tap(options) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/motion-wiretap/ios/wiretap_gestures.rb', line 121 def pan(target, =nil) fingers = nil min_fingers = nil max_fingers = nil delegate = nil if if .is_a? Hash fingers = [:fingers] min_fingers = [:min_fingers] max_fingers = [:max_fingers] delegate = [:delegate] else fingers = end end # if fingers is assigned, but not min/max, assign it as a default min_fingers ||= fingers max_fingers ||= fingers recognizer = UIPanGestureRecognizer.alloc.initWithTarget(target, action: 'handle_gesture:') recognizer.maximumNumberOfTouches = min_fingers if min_fingers recognizer.minimumNumberOfTouches = max_fingers if max_fingers recognizer.delegate = delegate if delegate return recognizer end |
.pinch(target, scale_or_options = nil) {|recognizer| ... } ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/motion-wiretap/ios/wiretap_gestures.rb', line 36 def pinch(target, =nil) scale = nil delegate = nil if if .is_a? Hash scale = [:scale] delegate = [:delegate] else scale = end end recognizer = UIPinchGestureRecognizer.alloc.initWithTarget(target, action: 'handle_gesture:') recognizer.scale = scale if scale recognizer.delegate = delegate if delegate return recognizer end |
.press(duration) ⇒ Object .press(options) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/motion-wiretap/ios/wiretap_gestures.rb', line 156 def press(target, =nil) duration = nil taps = nil fingers = nil delegate = nil if if .is_a? Hash duration = [:duration] taps = [:taps] fingers = [:fingers] delegate = [:delegate] else duration = end end recognizer = UILongPressGestureRecognizer.alloc.initWithTarget(target, action: 'handle_gesture:') recognizer.minimumPressDuration = duration if duration recognizer.numberOfTapsRequired = taps if taps recognizer.numberOfTouchesRequired = fingers if fingers recognizer.delegate = delegate if delegate return recognizer end |
.rotate(target, rotation_or_options = nil) {|recognizer| ... } ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/motion-wiretap/ios/wiretap_gestures.rb', line 56 def rotate(target, =nil) rotation = nil delegate = nil if if .is_a? Hash rotation = [:rotation] delegate = [:delegate] else rotation = end end recognizer = UIRotationGestureRecognizer.alloc.initWithTarget(target, action: 'handle_gesture:') recognizer.rotation = rotation if rotation recognizer.delegate = delegate if delegate return recognizer end |
.swipe(taps) ⇒ Object .swipe(options) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/motion-wiretap/ios/wiretap_gestures.rb', line 81 def swipe(target, ) direction = nil fingers = nil delegate = nil if if .is_a? Hash direction = [:direction] fingers = [:fingers] delegate = [:delegate] else direction = end end case direction when :left direction = UISwipeGestureRecognizerDirectionLeft when :right direction = UISwipeGestureRecognizerDirectionRight when :up direction = UISwipeGestureRecognizerDirectionUp when :down direction = UISwipeGestureRecognizerDirectionDown end recognizer = UISwipeGestureRecognizer.alloc.initWithTarget(target, action: 'handle_gesture:') recognizer.direction = direction if direction recognizer.numberOfTouchesRequired = fingers if fingers recognizer.delegate = delegate if delegate return recognizer end |
.tap(taps) ⇒ Object .tap(options) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/motion-wiretap/ios/wiretap_gestures.rb', line 13 def tap(target, =nil) taps = nil fingers = nil delegate = nil if if .is_a? Hash taps = [:taps] fingers = [:fingers] delegate = [:delegate] else taps = end end recognizer = UITapGestureRecognizer.alloc.initWithTarget(target, action: 'handle_gesture:') recognizer.numberOfTapsRequired = taps if taps recognizer.numberOfTouchesRequired = fingers if fingers recognizer.delegate = delegate if delegate return recognizer end |