Skip to content

Commit

Permalink
fix(gallery): use grab cursor for gallery items (#844)
Browse files Browse the repository at this point in the history
  • Loading branch information
2xAA authored Apr 8, 2023
1 parent 4b54059 commit 23bd5c3
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/components/GalleryItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
@mouseover="focus"
@mouseleave="blur"
@dblclick="doubleClick"
@mousedown="mouseDown"
v-if="!badModule"
class="gallery-item"
:class="{ grabbing }"
>
<canvas ref="canvas"></canvas>
<div class="title">{{ moduleName }}</div>
Expand All @@ -21,7 +23,8 @@ export default {
return {
id: "",
outputId: "",
badModule: false
badModule: false,
grabbing: false
};
},
Expand Down Expand Up @@ -89,6 +92,9 @@ export default {
groupId: this.groupId,
moduleId: this.id
});
// ensure listener cleanup
this.mouseUp();
},
methods: {
Expand Down Expand Up @@ -141,6 +147,16 @@ export default {
group => group.id === groupId
).modules.length
});
},
mouseDown() {
this.grabbing = true;
window.addEventListener("mouseup", this.mouseUp);
},
mouseUp() {
this.grabbing = false;
window.removeEventListener("mouseup", this.mouseUp);
}
}
};
Expand All @@ -153,13 +169,17 @@ canvas {
.gallery-item {
position: relative;
cursor: move;
cursor: grab;
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
.gallery-item.grabbing {
cursor: grabbing;
}
.gallery-item:hover canvas {
opacity: 1;
}
Expand Down

0 comments on commit 23bd5c3

Please sign in to comment.