Skip to content
Snippets Groups Projects
Commit 998d06b6 authored by Julian's avatar Julian
Browse files

Fix custom highlight element

parent 469b39d0
No related branches found
No related tags found
1 merge request!2Resolve "Implement basic functionality"
...@@ -62,6 +62,9 @@ import NumberCounter from "./components/NumberCounter.vue"; ...@@ -62,6 +62,9 @@ import NumberCounter from "./components/NumberCounter.vue";
<template #item="item"> <template #item="item">
<number-counter v-model="item.data.num"></number-counter> <number-counter v-model="item.data.num"></number-counter>
</template> </template>
<template #highlight>
<div ref="highlight" class="custom-highlight">Das hier ist das Highlight</div>
</template>
</drag-grid> </drag-grid>
<span>← Drag here please →</span> <span>← Drag here please →</span>
<drag-grid v-model="counters2" :cols="3" :rows="2" context="counter"> <drag-grid v-model="counters2" :cols="3" :rows="2" context="counter">
...@@ -293,6 +296,15 @@ export default { ...@@ -293,6 +296,15 @@ export default {
justify-content: space-between; justify-content: space-between;
} }
.custom-highlight {
display: flex;
align-items: center;
justify-content: center;
background: aquamarine;
width: 100%;
height: 100%;
}
.bordered { .bordered {
border: 2px solid grey; border: 2px solid grey;
} }
......
...@@ -4,9 +4,11 @@ ...@@ -4,9 +4,11 @@
@drop.prevent="handleDrop" @drop.prevent="handleDrop"
class="grid" class="grid"
> >
<slot name="highlight"> <div class="highlight-container" ref="highlightContainer">
<div class="highlight" ref="highlight"></div> <slot name="highlight">
</slot> <div class="highlight"></div>
</slot>
</div>
<DragContainer <DragContainer
v-for="item in value" v-for="item in value"
:key="item.key" :key="item.key"
...@@ -101,7 +103,7 @@ export default { ...@@ -101,7 +103,7 @@ export default {
let coords = this.getCoords(event.layerX, event.layerY); let coords = this.getCoords(event.layerX, event.layerY);
if (element.context !== this.context) { if (element.context !== this.context) {
this.$refs.highlight.style.display = "none"; this.$refs.highlightContainer.style.display = "none";
return; return;
} }
...@@ -116,18 +118,18 @@ export default { ...@@ -116,18 +118,18 @@ export default {
} }
if (!newPositionValid) { if (!newPositionValid) {
this.$refs.highlight.style.display = "none"; this.$refs.highlightContainer.style.display = "none";
return; return;
} }
this.$refs.highlight.style.display = "block"; this.$refs.highlightContainer.style.display = "block";
this.$refs.highlight.style.gridColumnStart = coords.x + ""; this.$refs.highlightContainer.style.gridColumnStart = coords.x + "";
this.$refs.highlight.style.gridRowStart = coords.y + ""; this.$refs.highlightContainer.style.gridRowStart = coords.y + "";
this.$refs.highlight.style.gridColumnEnd = "span " + element.w; this.$refs.highlightContainer.style.gridColumnEnd = "span " + element.w;
this.$refs.highlight.style.gridRowEnd = "span " + element.h; this.$refs.highlightContainer.style.gridRowEnd = "span " + element.h;
}, },
handleDrop(event) { handleDrop(event) {
this.$refs.highlight.style.display = "none"; this.$refs.highlightContainer.style.display = "none";
let data = event.dataTransfer.getData("vueDrag/gridItem"); let data = event.dataTransfer.getData("vueDrag/gridItem");
let element = JSON.parse(data); let element = JSON.parse(data);
...@@ -194,11 +196,18 @@ export default { ...@@ -194,11 +196,18 @@ export default {
.highlight { .highlight {
background: darkgrey; background: darkgrey;
border: grey dashed 2px; border: grey dashed 2px;
width: 100%;
height: 100%
}
.highlight-container {
display: none; display: none;
transition: all 2s ease-in-out; transition: all 2s ease-in-out;
z-index: -1; z-index: -1;
pointer-events: none; pointer-events: none;
user-select: none; user-select: none;
width: 100%;
height: 100%;
} }
.grid { .grid {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment