react-konva-grid
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -140,2 +140,8 @@ "use strict"; | ||
}; | ||
const boundsSubsetOfSelection = (bounds, selection) => { | ||
return (bounds.top >= selection.top && | ||
bounds.bottom <= selection.bottom && | ||
bounds.left >= selection.left && | ||
bounds.right <= selection.right); | ||
}; | ||
/** | ||
@@ -521,4 +527,28 @@ * Triggers a new selection start | ||
const bounds = selectionFromStartEnd(activeCell, coords); | ||
const hasSelections = selections.length > 0; | ||
const activeCellBounds = hasSelections | ||
? selections[0].bounds | ||
: gridRef.current.getCellBounds(activeCell); | ||
if (!bounds) | ||
return; | ||
/** | ||
* Restrict to same row and col | ||
*/ | ||
if (bounds.bottom !== activeCellBounds.bottom || | ||
bounds.top !== activeCellBounds.top) { | ||
bounds.left = activeCellBounds.left; | ||
bounds.right = activeCellBounds.right; | ||
} | ||
else if (bounds.left !== activeCellBounds.left) { | ||
bounds.top = activeCellBounds.top; | ||
bounds.bottom = activeCellBounds.bottom; | ||
} | ||
/** | ||
* If user moves back to the same selection, clear | ||
*/ | ||
if (hasSelections && | ||
boundsSubsetOfSelection(bounds, selections[0].bounds)) { | ||
setFillSelection(null); | ||
return; | ||
} | ||
setFillSelection({ bounds }); | ||
@@ -525,0 +555,0 @@ gridRef.current.scrollToItem(coords); |
{ | ||
"name": "react-konva-grid", | ||
"description": "Declarative React Canvas Grid primitive for Data table, Pivot table, Excel Worksheets", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
import React, { useState, useCallback, useRef, useEffect } from "react"; | ||
import { SelectionArea, CellInterface, GridRef } from "./../Grid"; | ||
import { SelectionArea, CellInterface, GridRef, AreaProps } from "./../Grid"; | ||
import { | ||
@@ -274,2 +274,11 @@ findNextCellWithinBounds, | ||
const boundsSubsetOfSelection = (bounds: AreaProps, selection: AreaProps) => { | ||
return ( | ||
bounds.top >= selection.top && | ||
bounds.bottom <= selection.bottom && | ||
bounds.left >= selection.left && | ||
bounds.right <= selection.right | ||
); | ||
}; | ||
/** | ||
@@ -715,4 +724,32 @@ * Triggers a new selection start | ||
const bounds = selectionFromStartEnd(activeCell, coords); | ||
const hasSelections = selections.length > 0; | ||
const activeCellBounds = hasSelections | ||
? selections[0].bounds | ||
: gridRef.current.getCellBounds(activeCell); | ||
if (!bounds) return; | ||
/** | ||
* Restrict to same row and col | ||
*/ | ||
if ( | ||
bounds.bottom !== activeCellBounds.bottom || | ||
bounds.top !== activeCellBounds.top | ||
) { | ||
bounds.left = activeCellBounds.left; | ||
bounds.right = activeCellBounds.right; | ||
} else if (bounds.left !== activeCellBounds.left) { | ||
bounds.top = activeCellBounds.top; | ||
bounds.bottom = activeCellBounds.bottom; | ||
} | ||
/** | ||
* If user moves back to the same selection, clear | ||
*/ | ||
if ( | ||
hasSelections && | ||
boundsSubsetOfSelection(bounds, selections[0].bounds) | ||
) { | ||
setFillSelection(null); | ||
return; | ||
} | ||
setFillSelection({ bounds }); | ||
@@ -719,0 +756,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
400055
8759