Skip to content

Commit

Permalink
Merge pull request #7 from yeoji/fix/4/multi-select-shift
Browse files Browse the repository at this point in the history
Fix broken multi select when new image is reloaded
  • Loading branch information
yeoji authored Feb 7, 2024
2 parents 0bf8933 + caa39c2 commit 71d9613
Show file tree
Hide file tree
Showing 7 changed files with 8,078 additions and 5,436 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2.3.1
uses: actions/checkout@v4

- name: Set Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x

- name: Setup Yarn 🧶
run: |
corepack enable
yarn set version stable
- name: Install and Build 🔧
run: |
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build Artifact on PR
on:
pull_request:
types:
- opened
- synchronize
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Set Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x

- name: Setup Yarn 🧶
run: |
corepack enable
yarn set version stable
- name: Install and Build 🔧
run: |
yarn install
yarn build
- name: Upload artifacts 📦
uses: actions/upload-artifact@v4
with:
name: gh-pages
path: dist
retention-days: 5
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@ node_modules
dist
.cache
.DS_Store

.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
5 changes: 5 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
compressionLevel: mixed

enableGlobalCache: false

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 71d9613

Please sign in to comment.