Skip to content

Commit

Permalink
Fix broken multi select when new image is reloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
yeoji committed Feb 6, 2024
1 parent 03ce21d commit 91b117d
Show file tree
Hide file tree
Showing 5 changed files with 8,020 additions and 5,435 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
dist
.cache
.DS_Store
.yarn
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"dependencies": {
"jquery": "^3.6.0",
"jszip": "^3.10.1"
"jszip": "^3.10.1",
"node-gyp": "^10.0.1"
}
}
17 changes: 11 additions & 6 deletions src/spritecow/SpriteCanvasView.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,20 @@ var SelectArea = (function() {
this._$eventArea = $eventArea;
this._highlight = highlight;
this._listeners = [];

this.createListeners();
}

var SelectAreaProto = SelectArea.prototype = new MicroEvent;
SelectAreaProto.activate = function() {

SelectAreaProto.createListeners = function() {
var selectArea = this,
rect = new Rect(0, 0, 0, 0),
startX, startY,
startPositionX, startPositionY,
isDragging,
$document = $(document);



selectArea._listeners.push([
selectArea._$eventArea, 'mousedown', function(event) {
if (event.button !== 0) { return; }
Expand Down Expand Up @@ -196,6 +197,10 @@ var SelectArea = (function() {
selectArea._highlight.hide();
}
]);
}

SelectAreaProto.activate = function() {
var selectArea = this;

selectArea._listeners.forEach(function(set) {
set[0].bind.apply( set[0], set.slice(1) );
Expand Down Expand Up @@ -244,8 +249,7 @@ class SpriteCanvasView {
spriteRect = spriteCanvas.expandToSpriteBoundry(rect);

spriteCanvasView._handleSelectedSprite(clickedRect, spriteRect);
}
else {
} else {
spriteCanvasView._unselectAllSprites();
}
});
Expand Down Expand Up @@ -289,6 +293,7 @@ SpriteCanvasViewProto._selectSprite = function(clickedRect, spriteRect) {

SpriteCanvasViewProto._unselectAllSprites = function() {
this._selectedSprites.forEach(sprite => sprite.unselect());
this._selectedSprites = [];
}

SpriteCanvasViewProto.setTool = function(mode) {
Expand Down
Loading

0 comments on commit 91b117d

Please sign in to comment.