admin管理员组文章数量:1415420
I am trying to make a chess game in react-js using react-dnd
I am trying to make draggable and droppable png images between different div(which represents the board squares)
I tried to set the opacity of the image background-color to 0 but it doesn't work
The problem is that images take the square background-color when i drag them Is it possible to remove it from the dragging image ? If not is there another drag and drop library that makes it possible ?
I am trying to make a chess game in react-js using react-dnd
I am trying to make draggable and droppable png images between different div(which represents the board squares)
I tried to set the opacity of the image background-color to 0 but it doesn't work
The problem is that images take the square background-color when i drag them Is it possible to remove it from the dragging image ? If not is there another drag and drop library that makes it possible ?
Share Improve this question asked Apr 13, 2019 at 19:06 LeoyinLeoyin 411 silver badge2 bronze badges 1- Wele, please see stackoverflow./help/how-to-ask on how to ask and stackoverflow./help/mcve how to create a minimal plete example – SakoBu Commented Apr 13, 2019 at 19:36
2 Answers
Reset to default 7you can add css style to your draggable element:
transform: translate(0, 0);
The key is to have the preview contain just the image of the piece, and not wrap more than that. If you edit your question to point to more code, I might be able to help you more.
For example:
const Knight = ({ connectDragSource, connectDragPreview, isDragging }) => {
return (
<>
<DragPreviewImage connect={connectDragPreview} src={knightImage} />
<div
ref={connectDragSource}
style={Object.assign({}, knightStyle, {
opacity: isDragging ? 0.5 : 1,
})}
>
♘
</div>
</>
)
}
Full code. See Knight.jsx
本文标签: javascriptIs it possible to remove background color when dragging png imageStack Overflow
版权声明:本文标题:javascript - Is it possible to remove background color when dragging png image? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745205874a2647636.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论