MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / _attach

Method _attach

packages/core/ui/gestures/index.ios.ts:134–265  ·  view source on GitHub ↗

* Given a singular GestureTypes value (e.g. GestureTypes.tap), adds a * UIGestureRecognizer for it and populates a RecognizerCache entry in * this._recognizers. * * Does not support attaching plural GestureTypes values, e.g. * GestureTypes.tap & GestureTypes.doubleTap.

(target: View, type: GestureTypes)

Source from the content-addressed store, hash-verified

132 * GestureTypes.tap & GestureTypes.doubleTap.
133 */
134 private _attach(target: View, type: GestureTypes) {
135 this._detach();
136
137 const nativeView = target?.nativeViewProtected as UIView | undefined;
138 if (!nativeView?.addGestureRecognizer) {
139 return;
140 }
141
142 switch (type) {
143 case GestureTypes.tap: {
144 nativeView.addGestureRecognizer(
145 this._createRecognizer(GestureTypes.tap, (args) => {
146 if (args.view) {
147 this._executeCallback(_getTapData(args));
148 }
149 }),
150 );
151 break;
152 }
153
154 case GestureTypes.doubleTap: {
155 nativeView.addGestureRecognizer(
156 this._createRecognizer(GestureTypes.doubleTap, (args) => {
157 if (args.view) {
158 this._executeCallback(_getTapData(args));
159 }
160 }),
161 );
162 break;
163 }
164
165 case GestureTypes.pinch: {
166 nativeView.addGestureRecognizer(
167 this._createRecognizer(GestureTypes.pinch, (args) => {
168 if (args.view) {
169 this._executeCallback(_getPinchData(args));
170 }
171 }),
172 );
173 break;
174 }
175
176 case GestureTypes.pan: {
177 nativeView.addGestureRecognizer(
178 this._createRecognizer(GestureTypes.pan, (args) => {
179 if (args.view) {
180 this._executeCallback(_getPanData(args, target.nativeViewProtected));
181 }
182 }),
183 );
184 break;
185 }
186
187 case GestureTypes.swipe: {
188 nativeView.addGestureRecognizer(
189 this._createRecognizer(
190 GestureTypes.swipe,
191 (args) => {

Callers 1

observeMethod · 0.95

Calls 9

_detachMethod · 0.95
_createRecognizerMethod · 0.95
_executeCallbackMethod · 0.95
_getTapDataFunction · 0.85
_getPinchDataFunction · 0.85
_getPanDataFunction · 0.85
_getSwipeDataFunction · 0.85
_getRotationDataFunction · 0.85
_getLongPressDataFunction · 0.85

Tested by

no test coverage detected