How to use the ve-range-utils.expandOrContractRangeToPosition 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 / withEditorInteractions / clickAndDragUtils.js View on Github external
//new range passed
        // return selectionLayerUpdate(newRange);
        let selectionFullyContained = !trimRangeByAnotherRange(
          selectionLayer,
          newRange
        );
        if (selectionFullyContained) {
          return selectionLayerUpdate(newRange);
        }

        let newRangeFullyContained = !trimRangeByAnotherRange(
          newRange,
          selectionLayer
        );

        let { newRange: range1 } = expandOrContractRangeToPosition(
          selectionLayer,
          newRange.start,
          sequenceLength
        );
        let { newRange: range2 } = expandOrContractRangeToPosition(
          selectionLayer,
          newRange.end + 1,
          sequenceLength
        ); //+1 to go from range end to position
        let range1Shorter =
          getRangeLength(range1, sequenceLength) <
          getRangeLength(range2, sequenceLength);

        if (newRangeFullyContained) {
          range1Shorter
            ? selectionLayerUpdate(range1)
github TeselaGen / openVectorEditor / src / withEditorInteractions / clickAndDragUtils.js View on Github external
);
        if (selectionFullyContained) {
          return selectionLayerUpdate(newRange);
        }

        let newRangeFullyContained = !trimRangeByAnotherRange(
          newRange,
          selectionLayer
        );

        let { newRange: range1 } = expandOrContractRangeToPosition(
          selectionLayer,
          newRange.start,
          sequenceLength
        );
        let { newRange: range2 } = expandOrContractRangeToPosition(
          selectionLayer,
          newRange.end + 1,
          sequenceLength
        ); //+1 to go from range end to position
        let range1Shorter =
          getRangeLength(range1, sequenceLength) <
          getRangeLength(range2, sequenceLength);

        if (newRangeFullyContained) {
          range1Shorter
            ? selectionLayerUpdate(range1)
            : selectionLayerUpdate(range2);
        } else {
          selectionLayerUpdate({
            start: selectionLayer.start,
            end: newRange.end
github TeselaGen / openVectorEditor / src / utils / selectionAndCaretUtils / updateSelectionOrCaret.js View on Github external
);
        if (selectionFullyContained) {
          return selectionLayerUpdate(newRange);
        }

        let newRangeFullyContained = !trimRangeByAnotherRange(
          newRange,
          selectionLayer
        );

        let { newRange: range1 } = expandOrContractRangeToPosition(
          selectionLayer,
          newRange.start,
          sequenceLength
        );
        let { newRange: range2 } = expandOrContractRangeToPosition(
          selectionLayer,
          newRange.end + 1,
          sequenceLength
        ); //+1 to go from range end to position
        let range1Shorter = getRangeLength(range1) < getRangeLength(range2);

        if (newRangeFullyContained) {
          range1Shorter
            ? selectionLayerUpdate(range1)
            : selectionLayerUpdate(range2);
        } else {
          range1Shorter
            ? selectionLayerUpdate(range2)
            : selectionLayerUpdate(range1);
        }
      }
github TeselaGen / openVectorEditor / src / utils / selectionAndCaretUtils / updateSelectionOrCaret.js View on Github external
} else {
        //new range passed
        let selectionFullyContained = !trimRangeByAnotherRange(
          selectionLayer,
          newRange
        );
        if (selectionFullyContained) {
          return selectionLayerUpdate(newRange);
        }

        let newRangeFullyContained = !trimRangeByAnotherRange(
          newRange,
          selectionLayer
        );

        let { newRange: range1 } = expandOrContractRangeToPosition(
          selectionLayer,
          newRange.start,
          sequenceLength
        );
        let { newRange: range2 } = expandOrContractRangeToPosition(
          selectionLayer,
          newRange.end + 1,
          sequenceLength
        ); //+1 to go from range end to position
        let range1Shorter = getRangeLength(range1) < getRangeLength(range2);

        if (newRangeFullyContained) {
          range1Shorter
            ? selectionLayerUpdate(range1)
            : selectionLayerUpdate(range2);
        } else {