Skip to content

Commit

Permalink
fix: made row drag highlight less 'jittery' and only show when it wou…
Browse files Browse the repository at this point in the history
…ld result in a change (#417)

* fix: made row drag highlight more visible

* fix: made row drag highlight less 'jittery' and only show when it would result in a change

* lint fix

* lint fix
  • Loading branch information
dclinz authored Sep 5, 2023
1 parent bf3d879 commit b37594f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/components/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,19 @@ export const Grid = ({
}, []);

const onRowDragMove = useCallback((event: RowDragMoveEvent) => {
const clientSideRowModel = event.api.getModel() as IClientSideRowModel;
clientSideRowModel.highlightRowAtPixel(event.node as RowNode<any>, event.y);
if (event.overNode && event.node.rowIndex != null) {
const clientSideRowModel = event.api.getModel() as IClientSideRowModel;

//position 0 means highlight above, 1 means below
const position = clientSideRowModel.getHighlightPosition(event.y, event.overNode as RowNode<any>);

//we don't want to show the row highlight if it wouldn't result in the row moving
const targetIndex = event.overIndex + position - (event.node.rowIndex < event.overIndex ? 1 : 0);
//console.log(targetIndex)
if (event.node.rowIndex != targetIndex) {
clientSideRowModel.highlightRowAtPixel(event.node as RowNode<any>, event.y);
}
}
}, []);

const onRowDragEnd = useCallback(
Expand Down
9 changes: 7 additions & 2 deletions src/styles/GridTheme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,15 @@ $grid-base-font-size: calc(#{lui.$base-font-size} - 1px);
background-color: transparent;
}

.ag-row-highlight-above::after{
.ag-row-highlight-above::after {
top:-3px; // moves the top highlight to the position of the bottom highlight
border-top: 2px dashed lui.$andrea;

}

.ag-row-highlight-above:first-of-type:after {
top:0px; // the first row highlight needs to in the normal position otherwise it is cut off by the top of the table
}

.ag-row-highlight-below::after {
border-bottom: 2px dashed lui.$andrea;
}
Expand Down

0 comments on commit b37594f

Please sign in to comment.