Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//shift + click
else if ( event.shiftKey ) {
//if we click on an already selected item, do nothing, else go in that if
if ( idx === -1 ) {
if ( selectedItems.length >= 1 ) {
let selectedIdx = itemIndex
//case only one item selected
let currentMin = selectedItems[0]
let currentMax = currentMin
//case multiple items already selected => set proper min & max to build the largest interval
if ( selectedItems.length > 1 ) {
currentMin = arrayMin( selectedItems )
currentMax = arrayMax( selectedItems )
}
let min = Math.min( selectedIdx, currentMin )
let max = Math.max( selectedIdx, currentMax )
//build the interval
let interval = []
let i = min
for ( i; i <= max; i++ ) {
interval.push( i )
}
onSelect( interval )