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

#73 Panning won't stop when mouseup occurs outside drawing area #586

Merged
merged 1 commit into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/svgcanvas/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,19 @@ export const mouseMoveEvent = function (evt) {
});
}; // mouseMove()

/**
*
* @returns {void}
*/
export const mouseOutEvent = function () {
const svgCanvas = eventContext_.getCanvas();
const { $id } = svgCanvas;
if(eventContext_.getCurrentMode() !== 'select' && eventContext_.getStarted()) {
const event = new Event("mouseup");
$id('svgcanvas').dispatchEvent(event);
}
};

// - in create mode, the element's opacity is set properly, we create an InsertElementCommand
// and store it on the Undo stack
// - in move/resize mode, the element's attributes which were affected by the move/resize are
Expand Down
4 changes: 3 additions & 1 deletion src/svgcanvas/svgcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
init as textActionsInit, textActionsMethod
} from './text-actions.js';
import {
init as eventInit, mouseMoveEvent, mouseUpEvent,
init as eventInit, mouseMoveEvent, mouseUpEvent, mouseOutEvent,
dblClickEvent, mouseDownEvent, DOMMouseScrollEvent
} from './event.js';
import { init as jsonInit, getJsonFromSvgElements, addSVGElementsFromJson } from './json.js';
Expand Down Expand Up @@ -1313,6 +1313,7 @@ class SvgCanvas {
* @returns {void}
*/
const mouseUp = mouseUpEvent;
const mouseOut = mouseOutEvent;

const dblClick = dblClickEvent;

Expand All @@ -1329,6 +1330,7 @@ class SvgCanvas {
container.addEventListener('click', handleLinkInCanvas);
container.addEventListener('dblclick', dblClick);
container.addEventListener('mouseup', mouseUp);
container.addEventListener('mouseleave', mouseOut);

// TODO(rafaelcastrocouto): User preference for shift key and zoom factor
container.addEventListener('mousewheel', DOMMouseScrollEvent);
Expand Down