DragSource์ด๊ธฐ๋ ํ ์ปดํฌ๋ํธ ๋ด๋ถ์ DragSource๊ฐ์๋ ๊ฒฝ์ฐ (์ฆ, ๋๋๊ทธ ๊ฐ๋ฅํ ๋ด๋ถ์์ ๋๋๊ทธ) ์์ ์ปดํฌ๋ํธ๋ฅผ ๋๋๊ทธ ํ ๋๋ง๋ค ๋ค์ ๊ฒฝ๊ณ ๊ฐ ๋ํ๋ฉ๋๋ค.
Warning: setState(...): Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state.
warning @ modules.js?hash=107dc56โฆ:19491
getInternalInstanceReadyForUpdate @ modules.js?hash=107dc56โฆ:5476
ReactUpdateQueue.enqueueSetState @ modules.js?hash=107dc56โฆ:5617
ReactComponent.setState @ modules.js?hash=107dc56โฆ:15132
handleChange @ modules.js?hash=107dc56โฆ:20844
handleChange @ modules.js?hash=107dc56โฆ:22861
dispatch @ modules.js?hash=107dc56โฆ:23568
addSource @ modules.js?hash=107dc56โฆ:23124
registerSource @ modules.js?hash=107dc56โฆ:21172
receiveType @ modules.js?hash=107dc56โฆ:21099
receiveProps @ modules.js?hash=107dc56โฆ:21089
DragSource(NestedComponent) @ modules.js?hash=107dc56โฆ:21062
ReactCompositeComponentMixin.mountComponent @ modules.js?hash=107dc56โฆ:6679
ReactCompositeComponent_mountComponent @ modules.js?hash=107dc56โฆ:896
ReactReconciler.mountComponent @ modules.js?hash=107dc56โฆ:5167
ReactMultiChild.Mixin.mountChildren @ modules.js?hash=107dc56โฆ:13562
ReactDOMComponent.Mixin._createContentMarkup @ modules.js?hash=107dc56โฆ:10901
ReactDOMComponent.Mixin.mountComponent @ modules.js?hash=107dc56โฆ:10789
ReactReconciler.mountComponent @ modules.js?hash=107dc56โฆ:5167
ReactCompositeComponentMixin._updateRenderedComponent @ modules.js?hash=107dc56โฆ:7101
ReactCompositeComponentMixin._performComponentUpdate @ modules.js?hash=107dc56โฆ:7075
ReactCompositeComponentMixin.updateComponent @ modules.js?hash=107dc56โฆ:7004
ReactCompositeComponent_updateComponent @ modules.js?hash=107dc56โฆ:896
ReactCompositeComponentMixin.receiveComponent @ modules.js?hash=107dc56โฆ:6936
ReactReconciler.receiveComponent @ modules.js?hash=107dc56โฆ:5217
ReactCompositeComponentMixin._updateRenderedComponent @ modules.js?hash=107dc56โฆ:7093
ReactCompositeComponentMixin._performComponentUpdate @ modules.js?hash=107dc56โฆ:7075
ReactCompositeComponentMixin.updateComponent @ modules.js?hash=107dc56โฆ:7004
ReactCompositeComponent_updateComponent @ modules.js?hash=107dc56โฆ:896
ReactCompositeComponentMixin.receiveComponent @ modules.js?hash=107dc56โฆ:6936
ReactReconciler.receiveComponent @ modules.js?hash=107dc56โฆ:5217
ReactCompositeComponentMixin._updateRenderedComponent @ modules.js?hash=107dc56โฆ:7093
ReactCompositeComponentMixin._performComponentUpdate @ modules.js?hash=107dc56โฆ:7075
ReactCompositeComponentMixin.updateComponent @ modules.js?hash=107dc56โฆ:7004
ReactCompositeComponent_updateComponent @ modules.js?hash=107dc56โฆ:896
ReactCompositeComponentMixin.performUpdateIfNecessary @ modules.js?hash=107dc56โฆ:6952
ReactReconciler.performUpdateIfNecessary @ modules.js?hash=107dc56โฆ:5232
runBatchedUpdates @ modules.js?hash=107dc56โฆ:5832
Mixin.perform @ modules.js?hash=107dc56โฆ:6304
Mixin.perform @ modules.js?hash=107dc56โฆ:6304
assign.perform @ modules.js?hash=107dc56โฆ:5789
flushBatchedUpdates @ modules.js?hash=107dc56โฆ:5850
ReactUpdates_flushBatchedUpdates @ modules.js?hash=107dc56โฆ:896
Mixin.closeAll @ modules.js?hash=107dc56โฆ:6370
Mixin.perform @ modules.js?hash=107dc56โฆ:6317
ReactDefaultBatchingStrategy.batchedUpdates @ modules.js?hash=107dc56โฆ:10295
enqueueUpdate @ modules.js?hash=107dc56โฆ:5879
enqueueUpdate @ modules.js?hash=107dc56โฆ:5460
ReactUpdateQueue.enqueueSetState @ modules.js?hash=107dc56โฆ:5626
ReactComponent.setState @ modules.js?hash=107dc56โฆ:15132
handleChange @ modules.js?hash=107dc56โฆ:21121
handleChange @ modules.js?hash=107dc56โฆ:22861
dispatch @ modules.js?hash=107dc56โฆ:23568
(anonymous function) @ modules.js?hash=107dc56โฆ:22100
endDragIfSourceWasRemovedFromDOM @ modules.js?hash=107dc56โฆ:29563
handleTopDrop @ modules.js?hash=107dc56โฆ:29860
์ด์ ๋ํ ์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
class ParentDraggable extends React.Component {
render() {
return this.props.connectDragSource(
<NestedDraggable/>
);
}
}
//... Skip the code for containers
class NestedDraggable extends React.Component {
render() {
return this.props.connectDragSource(
<div></div>
);
}
}
์ด ๋ฌธ์ ๋ ๋ถ๋ชจ ๊ตฌ์ฑ ์์๋ฅผ ๋ค์ ๋ ๋๋งํ๋ฉด receiveProps ํจ์ ํธ์ถ ์ค์ ์์ DragSource ํธ์ถ์ด setState๋ฅผ ํธ์ถํ๋ค๋ ์ฌ์ค์์ ๋น๋กฏ๋ ๊ฒ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค.
: +1 :
๋ฌธ์ ๋ฅผ ์ฌํํ๋ ํ๋ก์ ํธ๋ฅผ ์ ๊ณตํด ์ฃผ์๊ฒ ์ต๋๊น?
์ ๋ ๊ฐ๋จํ ์์ ๋ฅผ ๋ง๋ค๋ ค๊ณ ๋ ธ๋ ฅํ๊ณ ์์ผ๋ฉฐ ์ ๊ฐ ์์ ์ค์ธ ๊ฐ์ธ ํ๋ก์ ํธ ์ธ๋ถ์์ ์ฌ์์ฐํ๋ ๋ฐ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. @nihtalak , ๋ฌธ์ ๋ฅผ ์์ฑํ๋ Github์ ์ ์ฅ์๊ฐ ์์ต๋๊น?
๋ค์์ ์ค๋ช ๋ ๋์์ ๋ณด์ฌ์ฃผ๋ ์์ ์ ์ฅ์์ ๋๋ค. https://github.com/ebakan/react-dnd-nested-bug
ํฅ๋ฏธ๋กญ๊ฒ๋ Component
๋ monitor.getItem()
์์ ํ ๋๋ง์ด ์ค๋ฅ๋ฅผ ๋ฐ์์ํต๋๋ค. monitor.isDragging()
์์ ํ๋ ๊ฒฝ์ฐ https://github.com/ebakan/react-dnd-nested-bug/tree/no-error-with-is- ๋ธ๋์น์ ํ์๋๋๋ก ์ ๋๋ก ์๋ํฉ๋๋ค.
monitor.getItemType()
์ฒญ์ทจ ํ ๋๋ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. https://github.com/ebakan/react-dnd-nested-bug/tree/error-with-get-item-type
@ebakan- ํฅ๋ฏธ ๋กญ์ต๋๋ค. isDragging์ ์ฌ์ฉํ๋ ๋ด ์ฝ๋์์ด ๋ฒ๊ทธ๊ฐ ๋ํ๋๋ ์์ธ์ด ๋ฌด์์ธ์ง ๊ถ๊ธํฉ๋๋ค. ์ค์ฒฉ ๋ ๋๋๊ทธ ๊ฐ๋ฅ ํญ๋ชฉ์ ์ฌ์ฉํ์ฌ ์ด์ํ ์ผ์ํ๊ณ ์์ผ๋ฏ๋ก๋ณด๊ณ ์๋ ๊ฒ๊ณผ ๋์ผํ ๋ฒ๊ทธ๊ฐ ๋ํ๋ ์ ์์ต๋๋ค. ์ฌํ ํด์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค!
๋๋ ์ค์ฒฉ ๋๋๊ทธ ๊ฐ๋ฅ ํญ๋ชฉ๋ ์์ง๋ง ๊ทธ๊ฒ ๋ฌธ์ ์ธ์ง ํ์คํ์ง ์์ต๋๋ค.
์ ์์ ๊ณผ ๋ฃ๊ณ ์๋ ์ฝ๋๋ฅผ ๋ง๋๋ ๊ฒ ๊ฐ์ต๋๋ค. ๋์์ด๋๋ค๋ฉด ๋์์์ ๋ง๋ค์์ต๋๋ค.
http://screencast.com/t/qCrJRPAS2MYR
์
๋ฐ์ดํธ : ๋ฌธ์ ๋ฅผ ๋ฐ๊ฒฌํ๊ณ ๋จ์ ์ฒญ์ทจ์๊ฐ ์์์ผ๋ฏ๋ก ์ ๊ฒฝ์ฐ์๋ react-dnd ๋๋ฌธ์ด ์๋๋๋ค.
Update2 : ๋๋ฌด ๋นจ๋ฆฌ ๋ง ํ์ด์. ๋จ์ ์ฒญ์ทจ์๋ฅผ ์ ๊ฑฐํด๋ ์ฌ์ ํ ๊ฒฝ๊ณ ๊ฐ ํ์๋ฉ๋๋ค.
๋ฐฉ๊ธ Dnd๋ฅผ ๋ค๋ฅธ ๊ตฌ์ฑ ์์์ ์ถ๊ฐํ์ผ๋ฉฐ ์ค์ฒฉ๋๊ฑฐ๋ ์ฌ๋ฌ ๋๋๊ทธ ๊ตฌ์ฑ ์์๊ฐ ์์ด๋์ด ๋ฌธ์ ๋ฅผ ๋ฐ๊ฒฌํ์ต๋๋ค.
์ฝ๊ฐ์ ํ๊ณ ๋ฅผ ํ ํ ๋ฌธ์ ๊ฐ ๋๋๊ทธ๋๋ ๋์ ๊ตฌ์ฑ ์์๋ฅผ ๋ ๋๋งํ๋ ์ฌ์ฉ์ ์ ์ ๋๋๊ทธ ๋ ์ด์ด์ ์ฐ๊ฒฐ๋์ด ์์์ ๋ฐ๊ฒฌํ์ต๋๋ค.
๋๋๊ทธ๋๋ ๊ตฌ์ฑ ์์ ๋์ ํ ์คํธ๋ฅผ ๋ฃ์ผ๋ฉด ์ ๋๋ก ์๋ํฉ๋๋ค. ๊ตฌ์ฑ ์์ ์์ฒด๊ฐ ๋๋๊ทธ ์์ค์ ๋๋ค.
@jchristman @hakunin ์ค์ฒฉ ๋ ๋๋๊ทธ ๊ฐ๋ฅ ํญ๋ชฉ์ด ์์ง๋ง isDragging
๊ธฐ๋ฐ์ผ๋ก ์กฐ๊ฑด๋ถ๋ก ๋ ๋๋ง ๋ ๋๋กญ ๋์์ด์์ ๋ Cannot update during an existing state transition
๋ฐ์ํ์ต๋๋ค. ๊ทํ์ ์์์ ์ด๊ฒ์ด ํด๋น ๋ ์ ์์ต๋๊น? ๋ค์๊ณผ ๊ฐ์ ๊ฒ :
render() {
var dropZone;
if (this.props.isDragging) dropZone = <MyDropTarget />;
return <div>
<MyDragSource />
{dropZone}
</div>
}
๋๋๊ทธ๊ฐ ํ์ฑํ๋์์ ๋ ๊ตฌ์ฑ ์์๋ฅผ ์ถ๊ฐํ๊ณ ์ ๊ฑฐํ๋ ๋์ display: none/block
๋ฅผ ์ฌ์ฉํ์ฌ ๋์์ ์จ๊ธฐ๋ ๋ฐฉ์์ผ๋ก ์์
์ ๋๋์ต๋๋ค.
๊ทธ๊ฒ ๋ฌธ์ ๊ฐ ๋
Naw- "๋๋กญ"์ด ๋ฐ์ํ๋ฉด ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ ๊ตฌ์ฑ ์์๋ฅผ ๋ค์ ๋ ๋๋งํ๋ ค๊ณ ์๋ํ๊ณ ์ด ๊ฒฝ๊ณ ๋ฅผ ํ์ํฉ๋๋ค.
๋ด ๋๋๊ทธ ๋ฏธ๋ฆฌ๋ณด๊ธฐ๊ฐ DragSource (๋ด๊ฐํด์๋ ์๋๋) ์ธ ๊ตฌ์ฑ ์์ ์ผ ๋ ๋์ผํ ๊ฒฝ๊ณ ๋ฅผ ๋ฐ์์ต๋๋ค.
@jchristman ๋น์ ์ ์ด๊ฒ์ ๋ํ ํด๊ฒฐ์ฑ ์ ์๊ฐํด
์ค์ฒฉ ๋ dragSources๋ก ์์ ํ๊ณ ์ค์ฒฉ ๋ ๋ฆฌ์์ค๋ฅผ ์ญ์ ํ ๋ ๊ฐ์๊ธฐ์ด ์ค๋ฅ๊ฐ ํ์๋๊ธฐ ์์ํ์ต๋๋ค.
์์ ๋ฅผ ์ ๊ณต ํ ์ ์์ง๋ง ๋๊ตฐ๊ฐ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋์ง ๋๋ ์ ์ ํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์๋์ง ํ์ธํ๊ณ ์ถ์์ต๋๋ค.
๋ด ๋๋๊ทธ ๋ฏธ๋ฆฌ๋ณด๊ธฐ๊ฐ DragSource (๋ด๊ฐํด์๋ ์๋๋) ์ธ ๊ตฌ์ฑ ์์ ์ผ ๋ ๋์ผํ ๊ฒฝ๊ณ ๋ฅผ ๋ฐ์์ต๋๋ค.
๊ฐ์ฌํฉ๋๋ค @arjunu ๋ด ๊ฒฝ๊ณ ๋ ์ด๊ฒ์ผ๋ก ์ธํด ๋ฐ์ํ์ต๋๋ค!
๋๋ ์์ง๋ ์ด๊ฒ๋ค์ ๊ฐ๋ ๊ฐ์ง๊ณ ์์ผ๋ฏ๋ก ๋ค๋ฅธ ์ด์ ๋ ๊ณ ์ณ์ผ ํ ๊ฒ ๊ฐ์ต๋๋ค. ๋ด ํธ์ด ๋ ์ ์์ต๋๋ค :)
@ gharwood1 , ๋ฌธ์ ๊ฐ ํด๊ฒฐ ๋ ๋๊น์ง ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ณ ์์ต๋๋ค. ์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ค์ ๋ก ์ดํดํ๊ธฐ ์ํด ๋ช ์๊ฐ์ ๋ณด๋์ผ๋ฏ๋ก ์์ ์ ์์ฒญํ ์ ์์์ง๋ง ๊ฝค ๋ณต์กํด์ ๊ณ์ ์งํํ์ต๋๋ค. ์๊ฐ์ด ์์ด ... :-(
@gaearon ๋๋ ๋๊ตฐ๊ฐ๊ฐ ๋น๊ธธ ์์๋ ํ๋ก์ ํธ๋ฅผ ๋ง๋ค์ง๋ ์์์ง๋ง ํ์ํ ๊ฒฝ์ฐ ๋ง๋ค ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
๊ธฐ๋ณธ์ ์ผ๋ก ๋ด๊ฐ ์ฌ๊ธฐ์ํ๋ ค๋ ๊ฒ์ ์ ํจํฉ๋๋ค.
64 ํ์์ ์กฐ๊ฑด๋ถ๋ฅผ ๋นํ์ฑํํ๋ฉด ๋ชจ๋ ๊ฒ์ด ์ ์์ ๋๋ค
if (this.props.draggingSubject){
effectiveChildren.push(this.props.draggingSubject);
}
๊ทธ๋ฌ๋ ๋๋๊ทธ ์ด๋ฒคํธ์ ๊ฒฐ๊ณผ๊ฐ ์ํ์ ์์ ํ๊ณ ๊ตฌ์ฑ ์์๋ฅผ ๋ ๋๋งํ๊ธฐ ์์ํ๋ ์๊ฐ ์์ ๊ฒฝ๊ณ ๊ฐ ์์ฃผ ๋ฐ์ํ๊ธฐ ์์ํฉ๋๋ค.
์ด๋ฌ๋ฉด ์๋๋์?
์ฌ์ฉ ์ฌ๋ก๋ ๊ธฐ๋ณธ์ ์ผ๋ก ๋๋กญ ๋์์์ ํ์ฌ ๋๋๊ทธ ๋ ํญ๋ชฉ์ "๋ฏธ๋ฆฌ๋ณด๊ธฐ"ํ๋ ๊ฒ์ ๋๋ค. ์์ ๋ด์ฉ์ ๊ฐ๋ ์ฆ๋ช ์ ๋๋ค. ์์ง Redux ์คํ ์ด์ ์ฐ๊ฒฐ๋์ด ์์ง ์์ต๋๋ค. ์ด๊ฒ์ด ์ ํจํ์ง ํ์คํ์ง ์๊ธฐ ๋๋ฌธ์ ๋๋ค.
ํ , ๋ณ๊ฒฝ ์ฌํญ์ SubjectDisplayContent
๋ก์ปฌ๋ก ์ ์งํด๋ ๊ด์ฐฎ์ ๊ฒ ๊ฐ์ง๋ง ๋ณ๊ฒฝ ์ฌํญ์ด SubjectDisplay
๊น์ง ํ์ฅ๋๋ฉด ๊ฒฝ๊ณ ๊ฐ ๋ฐ์ํ๊ธฐ ์์ํฉ๋๋ค. ๋ฐ๋ผ์ ๊ธฐ๋ณธ์ ์ผ๋ก dropTarget์ด ๋ค๋ฅธ dropTarget์ ์์ ํ๋ props๋ฅผ ๋ณด๋ด๋ฉด react-dnd๊ฐ ์ง์ฆ์๋
๋๋ค. ์ด๊ฒ์ด ์์๋๋ ๊ฒ์
๋๊น, ๊ทธ๋ฆฌ๊ณ ๋ช ๊ฐ์ง๋ฅผ ๋ค์ ์๊ฐํด์ผํฉ๋๊น, ์๋๋ฉด dnd์ ๋ฒ๊ทธ์
๋๊น?
๋๊ฐ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค. ์ผ๋ถ ์ํฉ์์ ํ ์์๋ ๊ฒ์ ๊ฐ ์ค์ฒฉ ๋ ๋๋๊ทธ ๊ฐ๋ฅ ํญ๋ชฉ ์ฃผ์์ DragDropContext
๋ง๋๋ ๊ฒ์
๋๋ค. ๊ทธ๋ฌ๋ ์ด๊ฒ์ ์ฌ์ฉ์ ์ ์ DragLayer๋ฅผ ์ํ๋ ์ฆ์ ์๋ํ์ง ์์ต๋๋ค.
์ค์ฒฉ ๋ dropTargets๋ฅผ ์ํํ๋ ๊ฒ์ ์ ์ธํ๊ณ ๋ ๋์ผํ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ค๋ช
์๋ฅผ ๋๋ฌ ๋ณธ ํ
isOver (์ต์ ) : ๋๋๊ทธ ์์ ์ด ์งํ ์ค์ด๊ณ ํฌ์ธํฐ๊ฐ ํ์ฌ ์์ ์ ์์ ์์ผ๋ฉด true๋ฅผ ๋ฐํํฉ๋๋ค. ์ ํ์ ์ผ๋ก {shallow : true}๋ฅผ ์ ๋ฌํ์ฌ ์ค์ฒฉ ๋ ๋์์ด ์๋๋ผ ์์ ์ ๋ง ํธ๋ฒ๋ง๋๋์ง ์ฌ๋ถ๋ฅผ ์๊ฒฉํ๊ฒ ํ์ธํ ์ ์์ต๋๋ค.
(shallow is true ์ต์ ์ฌ์ฉ) ๋ถ๋ชจ dropTarget์ canDrop ํจ์์์ ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋์์ต๋๋ค. ๋ค๋ฅธ ์๋๋ฆฌ์ค์๋ ๋์ผํ๊ฒ ์ ์ฉ๋ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
@jchenjc ๋๋ ์ด๊ฒ์ ์๋ํ์ง๋ง ๋๋ฅผ ์ํด ์๋ํ์ง ์์์ต๋๋ค. ์์งํ ๋งํด์ ๋ด ์ํฉ์ ์ค์ฒฉ ๋ ๋๋๊ทธ ๋ฏธ๋ฆฌ๋ณด๊ธฐ + ๋๋๊ทธ ์์ค + ๋ชฉ๋ก์์ ์์ ํด์ผํ๋ ๋๋กญ ๋์์ผ๋ก ๋งค์ฐ ๋ณต์กํฉ๋๋ค.
FWIW : ์ค์ฒฉ ๋ ๋๋๊ทธ ์์ค์ ์ฌ์ฉ์ ์ ์ ๋๋๊ทธ ๋ ์ด์ด๊ฐ ์์ต๋๋ค. ์ฌ์ฉ์ ์ ์ ๋๋๊ทธ ๋ ์ด์ด๋ฅผ ์ ๊ฑฐํ๋ฉด ๋ฉ์์ง๊ฐ ์ฌ๋ผ์ง๋๋ค. ์คํ ์ถ์ ์ ๊ฒ์ฌํ๋ฉด ๋ฌธ์ ๊ฐ ์ฌ๊ธฐ์์๋ ๊ฒ์ฒ๋ผ ๋ณด์ ๋๋ค.
printWarning @ warning.js?8a56:36
warning @ warning.js?8a56:60
getInternalInstanceReadyForUpdate @ ReactUpdateQueue.js?6531:54
enqueueSetState @ ReactUpdateQueue.js?6531:200
ReactComponent.setState @ ReactComponent.js?702a:63
handleChange @ DragLayer.js?1cbc:124 <--------------
handleChange @ DragDropMonitor.js?0588:60
๊ด๋ จ ์ฝ๋๋ ์ฌ๊ธฐ์ ์์ต๋๋ค . ๋ค์ ๋ ๋๋ง์ ํธ๋ฆฌ๊ฑฐํ๊ธฐ ์ํด ๋ด ๊ฒฝ์ฐ ์ํ๊ฐ ๋ค๋ฅธ ์ด์ ๋ฅผ ์ดํด ๋ณด๊ฒ ์ต๋๋ค.
dragsource + droptarget์ด droptarget ์์ ์ค์ฒฉ๋์ด ์์ผ๋ฉด์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ด๋ฌํ ์ผ์ด ๋ฐ์ํ ์ด์ ์ค ํ๋๋ ๋ชฉ๋ก ๊ตฌ์ฑ ์์๋ฅผ ๋๋๊ทธ ํธ๋ฒ ์์น์ ๋ฐ๋ผ ์ํ ํ ์์ ์ ๊ฒฐ์ ํ๋ ๋จ์ผ ๋๋กญ ๋์์ผ๋ก ๋ง๋๋ ๋์ ๊ฐ ์ด๋ก ์ด ๋ชจ๋ ๋ชฉ๋ก ํญ๋ชฉ์ ๋๋กญ ๋์์ผ๋ก ๋ง๋ค์ด ๋ชฉ๋ก ๋๋๊ทธ ์ค ๋๋กญ์ ๋ถ๋ฌ์ํ๊ธฐ ๋๋ฌธ์ ๋๋ค. ํ์์ ๋ฐฉ๋ฒ์ ๋ด๊ฐ ๋ณธ ๋๋ถ๋ถ์ ๋ค๋ฅธ DnD ์์คํ ์ด ์์ ์ ์ํํ๋ ๋ฐฉ๋ฒ์ ๋๋ค.
๋๊ตฐ๊ฐ์๊ฒ ๋์์ด๋๋ ๊ฒฝ์ฐ๋ฅผ ๋๋นํ์ฌ : ์ฌ์ฉ์ ์ ์ ๋๋๊ทธ ๋ ์ด์ด์์ ๋๋๊ทธ ์์ค ์ธ ๊ตฌ์ฑ ์์๋ฅผ ๋ ๋๋ง ํ ๋ ํธ๋ฆฌํ๊ธฐ ๋๋ฌธ์์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค. ๋๋๊ทธ ์์ค ์ปดํฌ๋ํธ๋ฅผ ๋๋๊ทธํ๋ ค๊ณ ํ๋ ์ํฐํฐ์ ๋์ผํ๊ธฐ ๋๋ฌธ์ ์ฝ๋๋ฅผ ์ฌ์ฌ์ฉํ์ฌ "DRY"๋ฅผ ์ ์งํ๋ ๊ฒ์ด ํฉ๋ฆฌ์ ์ด์์ต๋๋ค. ๋๋ ๊ทธ๊ฒ์ด ๋ชจ๋ dragSource ์ฝ๋๋ฅผ ๊ฐ์ง๊ณ ์๋ค๋ ์ฌ์ค์ ๋ํด ์๊ฐํ์ง ์์๋ค. ๋๋์ ๋ณด๋ฉด, _ ๋ฌผ๋ก _ ๋๋๊ทธ ์์ค๊ฐ ์ปค์คํ ๋๋๊ทธ ๋ ์ด์ด์์ ๋ ๋๋ง๋๋ ๊ฒ์ ์ํ์ง ์์ ๊ฒ์ด๋ค.
๊ถ๊ทน์ ์ผ๋ก ๊ตฌ์ฑ ์์๋ฅผ ๊ธฐ๋ณธ ๊ตฌ์ฑ ์์๋ฅผ ๊ฐ์ธ๋ "Draggable"๋ฒ์ ์ผ๋ก ๋ถํ ํ ๋ค์ ์ฌ์ฉ์ ์ง์ ๋๋๊ทธ ๋ ์ด์ด์์ ๊ธฐ๋ณธ ๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํ์ต๋๋ค. ๋ ์ด์ ๊ฒฝ๊ณ ์์ด ๋ ๋์ ์ฝ๋! ๐
@davidjoy woah, ๊ณต์ ํด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค! ์ ๋ ๋๊ฐ์ ์ผ์ํ๊ณ ์์ต๋๋ค. ์๋ํด ๋ณผ ํ์๊ฐ ์์ต๋๋ค!
@davidjoy ๋ฐฉ๊ธ ๋ด
์ด ๋ฌธ์ ๋ ์ต๊ทผ ํ๋์ด ์์๊ธฐ ๋๋ฌธ์ ์๋์ผ๋ก ์ค๋๋ ๊ฒ์ผ๋ก ํ์๋์์ต๋๋ค. ๋ ์ด์ ํ๋์ด ๋ฐ์ํ์ง ์์ผ๋ฉด ํ์๋ฉ๋๋ค. ๊ทํ์ ๊ธฐ์ฌ์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋๊ตฐ๊ฐ์๊ฒ ๋์์ด๋๋ ๊ฒฝ์ฐ๋ฅผ ๋๋นํ์ฌ : ์ฌ์ฉ์ ์ ์ ๋๋๊ทธ ๋ ์ด์ด์์ ๋๋๊ทธ ์์ค ์ธ ๊ตฌ์ฑ ์์๋ฅผ ๋ ๋๋ง ํ ๋ ํธ๋ฆฌํ๊ธฐ ๋๋ฌธ์์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค. ๋๋๊ทธ ์์ค ์ปดํฌ๋ํธ๋ฅผ ๋๋๊ทธํ๋ ค๊ณ ํ๋ ์ํฐํฐ์ ๋์ผํ๊ธฐ ๋๋ฌธ์ ์ฝ๋๋ฅผ ์ฌ์ฌ์ฉํ์ฌ "DRY"๋ฅผ ์ ์งํ๋ ๊ฒ์ด ํฉ๋ฆฌ์ ์ด์์ต๋๋ค. ๋๋ ๊ทธ๊ฒ์ด ๋ชจ๋ dragSource ์ฝ๋๋ฅผ ๊ฐ์ง๊ณ ์๋ค๋ ์ฌ์ค์ ๋ํด ์๊ฐํ์ง ์์๋ค. ๋๋์ ๋ณด๋ฉด, _ ๋ฌผ๋ก _ ๋๋๊ทธ ์์ค๊ฐ ์ปค์คํ ๋๋๊ทธ ๋ ์ด์ด์์ ๋ ๋๋ง๋๋ ๊ฒ์ ์ํ์ง ์์ ๊ฒ์ด๋ค.
๊ถ๊ทน์ ์ผ๋ก ๊ตฌ์ฑ ์์๋ฅผ ๊ธฐ๋ณธ ๊ตฌ์ฑ ์์๋ฅผ ๊ฐ์ธ๋ "Draggable"๋ฒ์ ์ผ๋ก ๋ถํ ํ ๋ค์ ์ฌ์ฉ์ ์ง์ ๋๋๊ทธ ๋ ์ด์ด์์ ๊ธฐ๋ณธ ๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํ์ต๋๋ค. ๋ ์ด์ ๊ฒฝ๊ณ ์์ด ๋ ๋์ ์ฝ๋! ๐