Skip to content

Commit

Permalink
Desktop: Fixes #3628: Add scroll offset for dragging notes (#3651)
Browse files Browse the repository at this point in the history
The note draging was not taking into account the scroll distance.
This caused the notes to be dragged to a different location than the mouse.
This scroll offset should fix that issue.
  • Loading branch information
DarinDev1000 authored Sep 13, 2020
1 parent 58574a2 commit 374ee3b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ElectronClient/gui/ItemList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class ItemList extends React.Component {
return this.listRef.current ? this.listRef.current.offsetTop : 0;
}

offsetScroll() {
return this.scrollTop_;
}

UNSAFE_componentWillMount() {
this.updateStateItemIndexes();
}
Expand Down
2 changes: 1 addition & 1 deletion ElectronClient/gui/NoteList/NoteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class NoteListComponent extends React.Component {
}

dragTargetNoteIndex_(event:any) {
return Math.abs(Math.round((event.clientY - this.itemListRef.current.offsetTop()) / this.itemHeight)) - 1;
return Math.abs(Math.round((event.clientY - this.itemListRef.current.offsetTop() + this.itemListRef.current.offsetScroll()) / this.itemHeight));
}

noteItem_noteDragOver(event:any) {
Expand Down

0 comments on commit 374ee3b

Please sign in to comment.