拖放CDK:继续在开始列表中显示拖动的元素 [英] Drag Drop CDK: keep showing dragged element inside starting list

查看:142
本文介绍了拖放CDK:继续在开始列表中显示拖动的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用cdk拖放,因为我需要它来创建工作的POC. 我从此代码开始从文档网站. 我看到每次将元素拖动到列表之外时,该元素都会被隐藏,直到将其拖放到同一列表或另一个列表中为止.

I'm playing with cdk Drag and Drop cause I need it to create a POC for work. I started with this code from the documentation website. I saw that every time I drag an element outside its list, said element is hidden until I drop it in the same list or in another one.

所以请告诉我我是否错了,但是似乎拖动的元素不是列表项的副本,而是元素本身.

So tell me if I'm wrong, but it seems that the dragged element is not a copy of the list item, but instead it's the element itself.

最后,我希望列表在拖动其中一个元素时不更改其布局.

In conclusion I want the list to not change its layout while I'm dragging one of its elements.

长话短说:

当前行为

预期行为

在cdk文档中我什么都没找到.

I didn't found anything to do this in the cdk documentation.

推荐答案

在您的stackblitz中,更改cdk-drag-drop-connected-sorting-example.css

In your stackblitz change in cdk-drag-drop-connected-sorting-example.css

更改

.cdk-drag-placeholder {
  opacity: 0;
}

放入:(或将其删除)

.cdk-drag-placeholder {
  /* opacity: 0; */
}

它消失的原因是占位符的css样式.

the fact its disappearing is due to css styling of the placeholder.

如果要禁用排序.看看这里!

If you want to disable Sorting. Have a look HERE!

这篇关于拖放CDK:继续在开始列表中显示拖动的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆