How to use the ve-range-utils/getRangeLength function in ve-range-utils

To help you get started, we’ve selected a few ve-range-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TeselaGen / openVectorEditor / src / VectorEditor / VectorInteractionWrapper / index.js View on Github external
//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}) {