(
nextCell: [number, number],
selected_cells: ICellCoordinates[]
)
| 14 | } |
| 15 | |
| 16 | export function selectionCycle( |
| 17 | nextCell: [number, number], |
| 18 | selected_cells: ICellCoordinates[] |
| 19 | ) { |
| 20 | const {minRow, minCol, maxRow, maxCol} = selectionBounds(selected_cells); |
| 21 | |
| 22 | const [nextRow, nextCol] = nextCell; |
| 23 | const adjustedCell = [nextRow, nextCol]; |
| 24 | |
| 25 | if (nextRow > maxRow) { |
| 26 | // wrap back to first row |
| 27 | adjustedCell[0] = minRow; |
| 28 | |
| 29 | // try and increment column |
| 30 | if (nextCol + 1 > maxCol) { |
| 31 | adjustedCell[1] = minCol; |
| 32 | } else { |
| 33 | adjustedCell[1] = nextCol + 1; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | if (nextRow < minRow) { |
| 38 | // wrap to last row |
| 39 | adjustedCell[0] = maxRow; |
| 40 | |
| 41 | // try and decrement column |
| 42 | if (nextCol - 1 < minCol) { |
| 43 | adjustedCell[1] = maxCol; |
| 44 | } else { |
| 45 | adjustedCell[1] = nextCol - 1; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | if (nextCol > maxCol) { |
| 50 | // wrap back to first column |
| 51 | adjustedCell[1] = minCol; |
| 52 | |
| 53 | // try and increment row |
| 54 | if (nextRow + 1 > maxRow) { |
| 55 | adjustedCell[0] = minRow; |
| 56 | } else { |
| 57 | adjustedCell[0] = nextRow + 1; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | if (nextCol < minCol) { |
| 62 | // wrap back to last column |
| 63 | adjustedCell[1] = maxCol; |
| 64 | |
| 65 | // try and decrement row |
| 66 | if (nextRow - 1 < minCol) { |
| 67 | adjustedCell[0] = maxRow; |
| 68 | } else { |
| 69 | adjustedCell[0] = nextRow - 1; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | return adjustedCell; |
no test coverage detected
searching dependent graphs…