Skip to content

Commit

Permalink
fix: remove all listeners after gesture end
Browse files Browse the repository at this point in the history
this fixes deselect happening when clicking outside of the svg
  • Loading branch information
dvictor committed Oct 17, 2020
1 parent 3723f84 commit 8a18483
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ function setData(el, data) {
el.__data = data;
}
var graph = {
// build a doc out of what's on screen
// in a typical app, you'll do the other way around
nodes: Array.from(g.children).map(function (el) {
var m = el.transform.baseVal.getItem(0).matrix;
var n = {
Expand Down
2 changes: 2 additions & 0 deletions lib/dnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export function dnd(onInit, onMove, onEnd) {
var remove = function (e) {
document.removeEventListener('touchmove', onMouseMove);
document.removeEventListener('mousemove', onMouseMove);
document.removeEventListener('mouseup', remove);
document.removeEventListener('touchend', remove);
onEnd(e);
};
function onMouseDown(e) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "svg-editor-tools",
"version": "1.0.0",
"version": "1.0.1",
"description": "Primitives for building a browser based WYSWYG editor. Demo provided.",
"main": "lib/index.js",
"repository": "https://github.com/dvictor/svg-editor-tools",
Expand Down
2 changes: 2 additions & 0 deletions src/dnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export function dnd(
const remove = (e: MouseEvent) => {
document.removeEventListener('touchmove', onMouseMove);
document.removeEventListener('mousemove', onMouseMove);
document.removeEventListener('mouseup', remove);
document.removeEventListener('touchend', remove);
onEnd(e)
};
function onMouseDown(e: MouseEvent) {
Expand Down

0 comments on commit 8a18483

Please sign in to comment.