Skip to content

Commit

Permalink
Merge pull request #2118 from epam/#2112-the-hand-tool-is-still-follo…
Browse files Browse the repository at this point in the history
…wing-the-cursor-when-moving-outside-the-canvas

#2112: The hand tool is still following the cursor when moving outside the canvas
  • Loading branch information
St-Permiakov authored Jan 25, 2023
2 parents 2fc8c1d + 069ed54 commit 5664d59
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions packages/ketcher-react/src/script/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,13 @@ function domEventSetup(editor: Editor, clientArea: HTMLElement) {
{ target: document, eventName: 'mousemove' },
{ target: document, eventName: 'mouseup' },
{ target: document, eventName: 'mouseleave' },
{
target: clientArea,
eventName: 'mouseleave',
toolEventName: 'mouseLeaveClientArea'
},
{ target: clientArea, eventName: 'mouseover' }
].forEach(({ target, eventName }) => {
].forEach(({ target, eventName, toolEventName }) => {
editor.event[eventName] = new DOMSubscription()
const subs = editor.event[eventName]

Expand All @@ -676,7 +681,12 @@ function domEventSetup(editor: Editor, clientArea: HTMLElement) {
}
}

const isToolUsed = useToolIfNeeded(editor, eventName, clientArea, event)
const isToolUsed = useToolIfNeeded(
editor,
toolEventName || eventName,
clientArea,
event
)
if (isToolUsed) {
return true
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ketcher-react/src/script/editor/tool/hand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class HandTool {
this.editor.event.cursor.dispatch({ status: 'mouseover' })
}

mouseleave() {
mouseLeaveClientArea() {
this.begPos = null
this.endPos = null
this.editor.event.cursor.dispatch({ status: 'leave' })
Expand Down

0 comments on commit 5664d59

Please sign in to comment.