MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / onTouchSelect

Method onTouchSelect

tools/xsbug/behaviors.js:466–486  ·  view source on GitHub ↗
(code, x, y)

Source from the content-addressed store, hash-verified

464 code.stop();
465 }
466 onTouchSelect(code, x, y) {
467 var anchor = this.anchor;
468 var bounds = code.bounds;
469 var offset = code.hitOffset(x - bounds.x, y - bounds.y);
470 if (this.mode == LINE_MODE) {
471 if (anchor.from < offset)
472 offset = code.findLineBreak(offset, true);
473 else
474 offset = code.findLineBreak(offset, false);
475 }
476 else if (this.mode == WORD_MODE) {
477 if (anchor.from < offset)
478 offset = code.findWordBreak(offset, true);
479 else
480 offset = code.findWordBreak(offset, false);
481 }
482 if (anchor.from < offset)
483 code.select(anchor.from, offset - anchor.from);
484 else
485 code.select(offset, anchor.to - offset);
486 }
487};
488
489export class CodeScrollerBehavior extends ScrollerBehavior {

Callers 2

onTimeChangedMethod · 0.95
onTouchMovedMethod · 0.95

Calls 1

selectMethod · 0.45

Tested by

no test coverage detected