xhlife / vue3-grid-layout Goto Github PK
View Code? Open in Web Editor NEWAbout A draggable and resizable grid layout, for Vue3.
Home Page: https://github.com/xhlife/vue3-grid-layout
License: MIT License
About A draggable and resizable grid layout, for Vue3.
Home Page: https://github.com/xhlife/vue3-grid-layout
License: MIT License
当拖拽或者修改大小时,item里的异步组件会不断的重新渲染。
defineAsyncComponent({
loader: () => import('test.vue')
})
Following warning is logged in console.
[Vue warn]: Detected a possible deep change on field `value` ref, for nested changes please either set the entire ref value or use `setValue` or `handleChange`.
Could these lines be causing it?
vue3-grid-layout/src/components/Grid/GridLayout.vue
Lines 409 to 413 in 6582ab0
I'm able to drag however I can't drag to a new position.
This is the error I get in my console:
MouseEvent.mozPressure is deprecated. Use PointerEvent.pressure instead.
MouseEvent.mozInputSource is deprecated. Use PointerEvent.pointerType instead.
I'm using Firefox.
Edit:
Find out it has no effect
Will there be support for a horizontal compact option?
Hello, when I add new items to existing items, they are not added sequentially and are added randomly. Please look carefully at the id numbers written under the items.
Here is image :
https://ibb.co/6grS635
`const layout = reactive([
{"x":0,"y":0,w: 4, h: 10,"i":0, "uid":'123'},
{"x":4,"y":0,w: 4, h: 10,"i":1, "uid":'1234'},
]);
const itemTitle = (item) => {
let result = item.i;
if (item.static) {
result += " - Static";
}
return result;
}
let draggable = true
let resizable = true
let index = 0
let colNum = 12
let autoSize = true
onBeforeMount(async () => {
index = layout.length
})
const addItem = function () {
// Add a new item. It must haconstve a unique key!
console.log(layout.length)
layout.push({
x: (layout.length * 2) % (colNum || 12),
y: layout.length + (colNum || 12), // puts it at the bottom
w: 4,
h: 10,
i: index,
uid: uniqueId,
});
// Increment the counter to ensure key is always unique.
index++;
}
const removeItem = function (val) {
const index = layout.map(item => item.i).indexOf(val);
layout.splice(index, 1);
}`
<grid-layout :layout.sync="layout" :row-height="25" :is-draggable="draggable" :is-resizable="resizable" :vertical-compact="true" :use-css-transforms="true"> <grid-item v-for="item in layout" :x="item.x" :y="item.y" :w="item.w" :h="item.h" :i="item.i" </grid-item> </grid-layout>
I am using 2 grid layouts, one nested inside the other. (Both responsive not resizeable). THe girdd layout upadte gets called in loop and the grid become smallers
<grid-layout
v-bind="$attrs"
ref="gridLayout"
v-model:layout="widgetsToDisplay"
:col-num="layoutDefaults.colNum"
:cols="layoutDefaults.cols"
:is-mirrored="false"
:vertical-compact="true"
:margin="layoutDefaults.margin"
:use-css-transforms="false"
:row-height="layoutDefaults.rowHeight"
:auto-size="shouldAutosize"
data-test="vue-grid-layout"
>
<grid-item
v-for="item in widgetsToDisplay"
:key="item.i.UUID"
:x="item.x"
:y="item.y"
:w="item.w"
:h="item.h"
:i="item.i"
:min-w="widgetsSize[item.i.type].min[0]"
:min-h="widgetsSize[item.i.type].min[1]"
drag-allow-from=".widget-toolbar"
:max-w="widgetsSize[item.i.type].max[0]"
:max-h="widgetsSize[item.i.type].max[1]"
@resize="widgetResize"
@resized="widgetResize"
@moved="widgetMove"
:class="{
'html-widget': checkItemType(item, 'HTML'),
'is-cockpit-widget': checkItemType(item, 'Cockpit') || checkItemType(item, 'Access Control Cockpits')
}"
data-test="vue-grid-item"
>
....
// renders the same component again
....
</grid-item>
</grid-layout>
Vue:3
node: v20
Browser: chrome
Hi xhlife,
first off all, thanks for this project! <3
I have experienced an issue with the responsive feature.
Think of a layout with 3 x 3 cards.
While shrinking, the grid is responsive, but not collapsing to a 9x1 but to a 3x1 grid.
So the cards of one row are overlapping.
Does that happen others as well?
"vue3-grid-layout-next": "^1.0.6",
Thanks again!
如题,GridLayout.vue.d.ts有Props等类型;而GridItem不知道什么原因,d.ts中只有一个unknown类型的Component
这在TSX下使用会非常不友好,开发大哥有空可以看看是什么问题!
在vue2中,this.$refs.gridLayout.updateLayout()可以获取到,在vue3中没有抛出来吗?
layoutUpdate()这个方法没有抛出来吗
Can we have access to the source code of demo project in https://cxid.gitee.io/works/work/vue3-grid-layout/index.html
尝试过在GridItem移动事件中,删除源GridLayout中的layout数组中的item,再插入到目标GridLayout的layout数组中,但这样会引发handleDrag中的异常:
if (!mouseInGrid) {
let draggingIndex = layoutData.value[0].findIndex(ele => ele.i === itemId)
let removed = layoutData.value[0].splice(draggingIndex, 1)
console.log(layoutData.value[0], removed)
}
大概可以模仿drag-from-outside例子,但先要解决拖少源GridItem时从源数组上删除该项引发异常?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.