MCPcopy Create free account
hub / github.com/ampproject/amphtml / onTouchMove

Method onTouchMove

src/gesture-recognizers.js:278–317  ·  view source on GitHub ↗

@override

(e)

Source from the content-addressed store, hash-verified

276
277 /** @override */
278 onTouchMove(e) {
279 const {touches} = e;
280 if (touches && touches.length >= 1) {
281 const {clientX: x, clientY: y} = touches[0];
282 this.lastX_ = x;
283 this.lastY_ = y;
284 if (this.eventing_) {
285 // If already eventing, always emit new coordinates
286 this.emit_(false, false, e);
287 } else {
288 // Figure out whether or not we should start eventing
289 const dx = Math.abs(x - this.startX_);
290 const dy = Math.abs(y - this.startY_);
291 // Swipe is penalized slightly since it's one of the least demanding
292 // gesture, thus -10 in signalReady.
293 if (this.horiz_ && this.vert_) {
294 if (dx >= 8 || dy >= 8) {
295 this.signalReady(-10);
296 }
297 } else if (this.horiz_) {
298 if (dx >= 8 && dx > dy) {
299 this.signalReady(-10);
300 } else if (dy >= 8) {
301 return false;
302 }
303 } else if (this.vert_) {
304 if (dy >= 8 && dy > dx) {
305 this.signalReady(-10);
306 } else if (dx >= 8) {
307 return false;
308 }
309 } else {
310 return false;
311 }
312 }
313 return true;
314 } else {
315 return false;
316 }
317 }
318
319 /** @override */
320 onTouchEnd(e) {

Callers

nothing calls this directly

Calls 2

emit_Method · 0.95
signalReadyMethod · 0.80

Tested by

no test coverage detected