React-dnd: connectDragPreview() ꡬ성 μš”μ†Œλ„ 일반 ꡬ성 μš”μ†Œλ‘œ ν‘œμ‹œλ©λ‹ˆλ‹€.

에 λ§Œλ“  2017λ…„ 05μ›” 28일  Β·  3μ½”λ©˜νŠΈ  Β·  좜처: react-dnd/react-dnd

μ•„λ§ˆλ„ 이것은 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> λ³΄μ—¬μ€λ‹ˆλ‹€. λ‚˜λŠ” 그것을 거기에 보여주고 싢지 μ•Šκ³  단지 λ―Έλ¦¬λ³΄κΈ°λ‘œμ„œλ§Œ 보여주고 μ‹ΆμŠ΅λ‹ˆλ‹€. 이것이 달성될 수 μžˆμŠ΅λ‹ˆκΉŒ?

wontfix

λͺ¨λ“  3 λŒ“κΈ€

μ—¬κΈ° μžˆμŠ΅λ‹ˆλ‹€(μ‚¬μš©μž μ •μ˜ λ“œλž˜κ·Έ λ ˆμ΄μ–΄ μ‚¬μš©):
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()μ—μ„œ μœ„ μ½”λ“œλ₯Ό μ‚¬μš©ν•˜λ©΄ λ“œλž˜κ·Έν•˜λŠ” λ™μ•ˆ 미리보기가 ν‘œμ‹œλ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

이 λ¬Έμ œλŠ” 졜근 ν™œλ™μ΄ μ—†μ—ˆκΈ° λ•Œλ¬Έμ— μžλ™μœΌλ‘œ 였래된 κ²ƒμœΌλ‘œ ν‘œμ‹œλ˜μ—ˆμŠ΅λ‹ˆλ‹€. 더 μ΄μƒμ˜ ν™œλ™μ΄ μ—†μœΌλ©΄ νμ‡„λ©λ‹ˆλ‹€. κ·€ν•˜μ˜ 기여에 κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰