Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//no selection layer yet, so we'll start one if necessary
// 0 1 2 3 4 5 6 7 8 9
// c
// n
//
var dragEnd = {
start: caretPosition,
end: normalizePositionByRangeLength(nearestCaretPos - 1, sequenceLength, true)
}
var dragStart = {
start: nearestCaretPos,
end: normalizePositionByRangeLength(caretPosition - 1, sequenceLength, true)
}
if (caretPosition === nearestCaretPos) {
return // do nothing because nearestCaretPos === caretPosition
} else if (getRangeLength(dragEnd, sequenceLength) < getRangeLength(dragStart, sequenceLength)) {
draggingEnd = true; //the caret becomes the "selection end"
selectionLayerUpdate(dragEnd)
} else {
draggingEnd = false; //the caret becomes the "selection end"
selectionLayerUpdate(dragStart)
}
}
function handleCaretDrag({caretPosition, selectionLayer, selectionLayerUpdate, nearestCaretPos, sequenceLength}) {