GithubHelp home page GithubHelp logo

hcg1023 / vue3-dnd Goto Github PK

View Code? Open in Web Editor NEW
544.0 544.0 44.0 86.95 MB

React Dnd implementation in Vue Composition-api.

Home Page: https://www.vue3-dnd.com

License: MIT License

JavaScript 0.12% TypeScript 69.69% Vue 29.72% Shell 0.06% HTML 0.17% CSS 0.24%
drag drag-and-drop draggable react-dnd vue vue-dnd

vue3-dnd's Introduction

Vue3 Dn

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⭐

npm version CI install size npm bundle size GitHub open issues GitHub Stars GitHub Forks GitHub PR GitHub contributors npm download npm download per month Featured on Openbase MIT License

Docs

vue3-dnd.com

Contributors

Made with contrib.rocks.

Thanks

React-Dnd

vue3-dnd's People

Contributors

balobba avatar github-actions[bot] avatar hcg1023 avatar liyue118 avatar poerlang avatar yu57494417 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vue3-dnd's Issues

Plans to support iOS?

I noticed all the demo examples are broken on iPhone, even the simple examples. Is this something thats on the roadmap?

Variable conflict: Cannot read properties of undefined (reading 'NODE_ENV')

框架 Vue3
我在使用过程中,产生了一些有趣的Bug;
企业微信截图_17102426525077
问题产生原因: 我使用的某个依赖,定义全局global.process属性,于是就产生了这个有趣的报错;
企业微信截图_17102430192760
从报错代码片段截图可以看出,有方法进行检测process.env.NODE_ENV, 然而它并不存在。

拖拽会执行多次onUpdated

`
....
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 里就可以复现的,想知道为什么拖拽会导致更新

使用vue-tsc && vite build编译之后,页面console报错

如题,在vite中新建一个项目之后,使用DndProvider :backend="HTML5Backend"包裹了div之后,直接vite跑起来没有问题,但是在使用vue-tsc && vite build编译之后,在http-server中跑起来访问静态页面时,控制台报错:Invariant Violation: Expected drag drop context

请问这个问题有什么解决办法吗?

You should know before you ask questions

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.

缩放功能

能否扩展一下组件,添加一个元素大小缩放的功能呢?

如何获取Drop所在的DOM节点?

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

Invariant Violation: Expected targetIds to be registered.

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)

关于vue3的toRefs

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,很奇怪为什么

useDrag 无法配置beginDrag参数

问题

想要实现控制某个拖拽源(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;来达到目的。不知能否实现,或者可以有其他解决方式?谢谢

useDrop isOver在进入放置目标时会变化两次?

拖动元素进入放置目标(无嵌套)时, 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
请教是什么原因呢

是否支持vue2.6+,且是js的项目

如题,请问 是否支持vue2.6+,且是js的项目?
项目依赖:vue2.6.14 + js

我想用这个库,报错:

  1. inject() can only be used inside setup() or functional components.
  2. "Invariant Violation: Expected drag drop context"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.