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

fix(gallery): use grab cursor for gallery items #844

Merged
merged 1 commit into from
Apr 8, 2023
Merged
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
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