μλ§λ μ΄κ²μ https://github.com/react-dnd/react-dnd/issues/399μ κ°λ₯ν μ€λ³΅μΌ κ²μ
λλ€
μ΄κ²μ μλ§λ μλ €μ§ λμμ΄μ§λ§ λ€μμ λ¬μ±ν μ μλ€λ©΄ μ’μ κ²μ
λλ€.
render () {
const { connectDragSource, connectDragPreview, isDragging } = this.props;
return (
<div className='top'>
<div>Ordinary</div>
{connectDragSource (<div>Dragabble</div>)}
{connectDragPreview (<div>my preview</div>)}
</div>
);
}
λ΄ λ―Έλ¦¬ 보기 κ΅¬μ± μμλ₯Ό μΌλ° κ΅¬μ± μμκ° μλ μ€μ 미리 보기λ‘λ§ νμνκ³ μΆμ΅λλ€.
κ·Έλ¬λ μ΄κ²μ 'μλ¨' div λ΄λΆμ μ€μ λλκ·Έ κ°λ₯ν κ΅¬μ± μμ μλμ <div>my preview</div>
보μ¬μ€λλ€. λλ κ·Έκ²μ κ±°κΈ°μ 보μ¬μ£Όκ³ μΆμ§ μκ³ λ¨μ§ 미리보기λ‘μλ§ λ³΄μ¬μ£Όκ³ μΆμ΅λλ€. μ΄κ²μ΄ λ¬μ±λ μ μμ΅λκΉ?
μ¬κΈ° μμ΅λλ€(μ¬μ©μ μ μ λλκ·Έ λ μ΄μ΄ μ¬μ©):
https://github.com/react-dnd/react-dnd/blob/master/examples/02%20Drag%20Around/Custom%20Drag%20Layer/CustomDragLayer.js
μ΄κ²μ μ½λμ κ΄λ ¨ λΆλΆμ λλ€.
import { getEmptyImage } from 'react-dnd-html5-backend';
componentDidMount() {
// Use empty image as a drag preview so browsers don't draw it
// and we can draw whatever we want on the custom drag layer instead.
if (this.props.connectDragPreview) {
this.props.connectDragPreview(getEmptyImage(), {
// IE fallback: specify that we'd rather screenshot the node
// when it already knows it's being dragged so we can hide it with CSS.
captureDraggingState: true,
});
}
}
μλ
νμΈμ
dragSource κ΅¬μ± μμ μμ μ¬μ©μ μ μ dragPreview κ΅¬μ± μμλ₯Ό λΉλν΄μΌ νμ§λ§ componentDidMount()μμ μ μ½λλ₯Ό μ¬μ©νλ©΄ λλκ·Ένλ λμ λ―Έλ¦¬λ³΄κΈ°κ° νμλμ§ μμ΅λλ€.
μ΄ λ¬Έμ λ μ΅κ·Ό νλμ΄ μμκΈ° λλ¬Έμ μλμΌλ‘ μ€λλ κ²μΌλ‘ νμλμμ΅λλ€. λ μ΄μμ νλμ΄ μμΌλ©΄ νμλ©λλ€. κ·νμ κΈ°μ¬μ κ°μ¬λ립λλ€.