src/util/freehand/insertOrDelete.js
/**
 * Gets the handle index of a tool in which to insert the new point.
 * @private
 * @method
 *
 * @param {Object} insertInfo - Object containing information about where to insert the point.
 * @returns {void}
 */
Gets the handle index of a tool in which to insert the new point.
@private
@method

@param {Object} insertInfo - Object containing information about where to insert the point.
@returns {void}
Gets the handle index of a tool in which to insert the new point . @private @method @param { Object } insertInfo - Object containing information about where to insert the point . @returns { void }
function _getInsertionIndex(insertInfo) {
  const handleIndexArray = insertInfo.handleIndexArray;
  let insertIndex = Infinity;
  const arrayContainsZero = handleIndexArray.includes(0);
  for (let i = 0; i < handleIndexArray.length; i++) {
    const index = handleIndexArray[i];
    if (index !== 0 && index < insertIndex) {
      insertIndex = index;
    }
  }
  if (arrayContainsZero && insertIndex === 1) {
    insertIndex = 0;
  }
  insertIndex++;
  return insertIndex;
}
function _getInsertionIndex ( insertInfo ) { const handleIndexArray = insertInfo . handleIndexArray ; let insertIndex = Infinity ; const arrayContainsZero = handleIndexArray . includes ( 0 ) ; for ( let i = 0 ; i < handleIndexArray . length ; i ++ ) { const index = handleIndexArray [ i ] ; if ( index !== 0 && index < insertIndex ) { insertIndex = index ; } } if ( arrayContainsZero && insertIndex === 1 ) { insertIndex = 0 ; } insertIndex ++ ; return insertIndex ; }
Gets the handle index of a tool in which to insert the new point.
Gets the handle index of a tool in which to insert the new point .
// Get lowest index that isn't zero // Treat the special case of handleIndexArray === [0,1] || [1,0] // The insertion index shall be just after the lower index