Skip to content
Snippets Groups Projects

Resolve "Implement basic functionality"

Merged Julian requested to merge 1-implement-basic-functionality into main
1 file
+ 37
10
Compare changes
  • Side-by-side
  • Inline
+ 37
10
@@ -13,15 +13,15 @@
@@ -13,15 +13,15 @@
v-for="item in value"
v-for="item in value"
:key="item.key"
:key="item.key"
:drag-i-d="item.key"
:drag-i-d="item.key"
:x="get('x', item)"
:x="getInt('x', item)"
:y="get('y', item)"
:y="getInt('y', item)"
:w="get('w', item)"
:w="getInt('w', item)"
:h="get('h', item)"
:h="getInt('h', item)"
:data="item.data"
:data="getObject('data', item)"
:context="context"
:context="context"
:grid-id="gridId"
:grid-id="gridId"
>
>
<slot v-bind="item" name="item">
<slot v-bind="transformItem(item)" name="item">
<dl>
<dl>
<dt>Key</dt>
<dt>Key</dt>
<dd>{{ item.key }}</dd>
<dd>{{ item.key }}</dd>
@@ -88,8 +88,14 @@ export default {
@@ -88,8 +88,14 @@ export default {
for (let item of this.value) {
for (let item of this.value) {
if (key === item.key) continue;
if (key === item.key) continue;
if (x >= item.x && x < item.x + item.w) {
if (
if (y >= item.y && y < item.y + item.h) {
x >= this.getInt("x", item) &&
 
x < this.getInt("x", item) + this.getInt("w", item)
 
) {
 
if (
 
y >= this.getInt("y", item) &&
 
y < this.getInt("y", item) + this.getInt("h", item)
 
) {
return false;
return false;
}
}
}
}
@@ -184,9 +190,30 @@ export default {
@@ -184,9 +190,30 @@ export default {
y: Math.ceil(y / (this.$el.offsetHeight / this.rows)),
y: Math.ceil(y / (this.$el.offsetHeight / this.rows)),
};
};
},
},
get(property, item) {
getInt(property, item) {
let val = item[property] || 1;
let val = item[property] || 1;
return val instanceof Function ? val(this) : parseInt(val);
return val instanceof Function ? val(this.gridData) : parseInt(val);
 
},
 
getObject(property, item) {
 
let val = item[property] || {};
 
return val instanceof Function ? val(this.gridData) : val;
 
},
 
transformItem(item) {
 
let newItem = { key: item.key };
 
newItem.x = this.getInt("x", item);
 
newItem.y = this.getInt("y", item);
 
newItem.w = this.getInt("w", item);
 
newItem.h = this.getInt("h", item);
 
newItem.data = this.getObject("data", item);
 
return newItem;
 
},
 
},
 
computed: {
 
gridData() {
 
return {
 
gridId: this.gridId,
 
context: this.context,
 
};
},
},
},
},
};
};
Loading