Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New suggestion for the rule for moving dragged row above or below a row. #71

Open
rtavassoli opened this issue Feb 21, 2022 · 1 comment

Comments

@rtavassoli
Copy link

Hi, thanks for the component, very helpful. I have a suggestion for onDragOverEventListener. Instead of deciding if moving above or below a row via the offset, I think the following is more straight forward and comprehensible for the user. The way it is built now, the decision if above or below changes when moving over the middle of a row, which I personally think is too "jumpy":

  • when on a row which is above the row being dragged, you want to move it above that row
  • when on a row which is below the row being dragged, you want to move it below that row
  • when on the same row, you don't want to move the row.

So instead of checking for (offset < this.offsetHeight / 2), I did the following:

onDragOverEventListener: function (e) {
...
uiGridDraggableRowsCommon.toIndex = data().indexOf($scope.$parent.$parent.row.entity);
if (uiGridDraggableRowsCommon.toIndex < uiGridDraggableRowsCommon.fromIndex) {
...
} else if (uiGridDraggableRowsCommon.toIndex > uiGridDraggableRowsCommon.fromIndex) {
...
}
else {
$element.removeClass(uiGridDraggableRowsConstants.ROW_OVER_ABOVE_CLASS);
$element.removeClass(uiGridDraggableRowsConstants.ROW_OVER_BELOW_CLASS);
}

Any problems this could create?
Thank you

@rtavassoli
Copy link
Author

By the way, the logic of moving the row inside the onDropEventListener function has to be changed accordingly. I also removed the $element classes in the onDropEventListener, because it seemed that in some situations they weren't removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant