React Dnd implementation in Vue Composition-api.
Supports Vue2 and Vue3
If you think this project is helpful to you, I hope you can contribute a star⭐
Made with contrib.rocks.
React Dnd implementation in Vue Composition-api.
Home Page: https://www.vue3-dnd.com
License: MIT License
React Dnd implementation in Vue Composition-api.
Supports Vue2 and Vue3
If you think this project is helpful to you, I hope you can contribute a star⭐
Made with contrib.rocks.
请问可以改变拖拽时鼠标样式吗?比如cursor: grabbing
I noticed all the demo examples are broken on iPhone, even the simple examples. Is this something thats on the roadmap?
https://www.vue3-dnd.com/example/dustbin/multiple-targets.html
复制粘贴使用的官方例子,报错。
相关版本使用:
vue3-dnd:2.0.4
vue:3.2.20
Hejhej,
the vue3-dnd-test-utils mention the need of the peerDependency "@testing-library/vue": ">= 11"
, but the latest version I can find is 7.0.0 (https://github.com/testing-library/vue-testing-library/tags)
Did I'm missing something? Or is this the wrong dependency?
Thx! :)
`
....
const setRef = (el: HTMLDivElement) => {
card.value = drag(drop(el)) as HTMLDivElement
}
onMounted(() => {
console.log('创建')
})
onUnmounted(() => {
console.log('销毁')
})
onUpdated(() => {
console.log('更新')
})
`
这个代码是examples\04-sortable\simple\Card.vue 里就可以复现的,想知道为什么拖拽会导致更新
如题,在vite中新建一个项目之后,使用DndProvider :backend="HTML5Backend"包裹了div之后,直接vite跑起来没有问题,但是在使用vue-tsc && vite build编译之后,在http-server中跑起来访问静态页面时,控制台报错:Invariant Violation: Expected drag drop context
请问这个问题有什么解决办法吗?
Most of the functions of vue3-dnd depend on react-dnd. If you encounter unknown problems, you can try to find them in the react-dnd community. Of course, you can also ask questions in the vue3-dnd community, and we will answer them as soon as possible.
能否扩展一下组件,添加一个元素大小缩放的功能呢?
如何实现数据拖拽指定距离后,拖拽源才能被拖拽?
如题,感谢
vue3-dnd: 2.0.2
vue: 3.2.37
您好,我有一个问题想请教一下。
我该如何获取drop所在的DOM节点?
const [collectedProps, drop] = useDrop(() => ({...}));
通过:ref="drop"
传递给dom节点,在后续的方法中我想通过drop.value获取dom,但是不可行,我从文档中没能确定是否可以通过该方法获取dom。我想获取dom节点之后,通过getClientOffset的值来计算鼠标相对于drop所在节点的相对位置。通常在vue3就是通过ref来绑定获取dom的,但是这里被占用了,我也可以通过直接操作dom来实现,但是我认为该方法不好,您能提供一些建议吗?
@hcg1023
I have issues similar to 763 and 3403 in the current version of the package.
I investigated this issue and concluded that it is necessary to update the dnd-core
package (as a dependency) to the latest version.
ERROR
Expected targetIds to be registered.
Invariant Violation: Expected targetIds to be registered.
at invariant (webpack-internal:///./node_modules/@react-dnd/invariant/dist/esm/index.mjs:26:21)
at checkInvariants (webpack-internal:///./node_modules/vue3-dnd/node_modules/dnd-core/dist/esm/actions/dragDrop/hover.mjs:40:72)
at DragDropManagerImpl.hover (webpack-internal:///./node_modules/vue3-dnd/node_modules/dnd-core/dist/esm/actions/dragDrop/hover.mjs:17:9)
at Object.eval [as hover] (webpack-internal:///./node_modules/vue3-dnd/node_modules/dnd-core/dist/esm/classes/DragDropManagerImpl.mjs:25:46)
at eval (webpack-internal:///./node_modules/react-dnd-html5-backend/dist/esm/HTML5BackendImpl.mjs:316:38)
const [collect, drag] = useDrag(() => ({
type: ItemTypes.BOX,
item: () => ({
name: props.name,
}),
end: (item, monitor) => {
const dropResult = monitor.getDropResult<DropResult>();
if (item && dropResult) {
alert(`You dropped ${item.name} into ${dropResult.name}!`);
}
},
collect: (monitor) => ({
isDragging: monitor.isDragging(),
handlerId: monitor.getHandlerId(),
}),
}));
const { isDragging } = toRefs(collect);
const opacity = computed(() => (unref(isDragging) ? 0.4 : 1));
这一段代码,例子里面是从@vueuse/core导入toRefs函数,但是如果直接从vue3里面引用toRefs函数,最终结果会失去响应式并且提示"expects a reactive object but received a plain one.",但是我针对collect对象使用isRef判断,得出的又是true,很奇怪为什么
想要实现控制某个拖拽源(Drag Sources)不可拖拽
想在在canDrag
内部调用 monitor.getItem()
来判断当前是否可被拖拽。
但发现canDrag
是在item
函数之前执行的,所以内部的 monitor.getItem()
函数return的一直是null
看了下react-dnd发现可以配置beginDrag
参数,它是在canDrag
之前来执行的
可以配置beginDrag
参数,让canDrag
内部可以获取到item数据
一开始用你这个有些懵, 你这个文档实例中,能把代码贴上去吗
我看例子里没有这种例子,不知道如何实现通过单击或者双击将拖拽源放到指定的放置目标默认位置,例子好像只能通过拖拽放置,双击是较为常用场景,单击放置是想实现如PS工具那种,通过下拉窗口点击对应工具,会在编辑区默认位置放置一个对应工具
您好,我在使用过程中有个难以处理的地方,就是拖动时生成的previewImage阻挡了鼠标与下面元素的交互事件,比如拖动过程中希望触发下面元素的mouseenter,mouseleave等事件,所以期望可以通过设置previewImage样式pointer-events: none;来达到目的。不知能否实现,或者可以有其他解决方式?谢谢
vite:4.3.9
vue: 3.3.4
本地运行无任何报错,一打包到线上就报:Cannot read properties of undefined (reading 'NODE_ENV')
代码是和官方列子copy的。
拖动元素进入放置目标(无嵌套)时, isOver会进行true -> false -> true的变化
const [dropCollect, drop] = useDrop({
accept: ['BOX'],
collect: monitor => ({
isOver: monitor.isOver({ shallow: true })
})
})
const { isOver } = toRefs(dropCollect)
watch(isOver, val => {
console.log('val')
})
// true
// false
// true
拖动进入时, 会打印true -> false -> true
请教是什么原因呢
拖动结束时,dragpreview元素会默认有一个返回起始位置的动画
自定义dragpreview元素时也会有接近1秒的等待时间, 才会dragend
这一段动画可以提供状态控制的接口?
i find it not work for element plus ,
如题,官方文档中的例子没有,有嵌套但是效果和想象中的不太一样!
使用 react-dnd-touch-backend,拖拽预览不生效。
Whether or not a transition animation has been added to the sorting,thanks
如题,请问 是否支持vue2.6+,且是js的项目?
项目依赖:vue2.6.14 + js
我想用这个库,报错:
文档中提到,end 时,已经不再拖拽了,所以返回的 monitor.getXXXOffset 是 null,但我依然想获得鼠标松开时的坐标,如何做比较好?
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.