카드 드래그시 뒷쪽에 있는 카드쪽 위치 오류 수정
This commit is contained in:
@@ -114,13 +114,7 @@ function _onDragEnter(e) {
|
|||||||
if (isSrc) return;
|
if (isSrc) return;
|
||||||
|
|
||||||
_dropTargetIdx = idx;
|
_dropTargetIdx = idx;
|
||||||
|
_grid.insertBefore(_placeholder, this);
|
||||||
// 플레이스홀더를 삽입될 위치로 이동
|
|
||||||
if (dragMode === 'single' && dragSrcIdx < idx) {
|
|
||||||
_grid.insertBefore(_placeholder, this.nextSibling); // 오른쪽으로 이동: 타겟 뒤
|
|
||||||
} else {
|
|
||||||
_grid.insertBefore(_placeholder, this); // 왼쪽 이동 또는 multi: 타겟 앞
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _onDragLeave() {
|
function _onDragLeave() {
|
||||||
@@ -243,9 +237,9 @@ function _onGridDrop(e) {
|
|||||||
|
|
||||||
function _moveSingle(srcIdx, targetIdx) {
|
function _moveSingle(srcIdx, targetIdx) {
|
||||||
const [moved] = _state.files.splice(srcIdx, 1);
|
const [moved] = _state.files.splice(srcIdx, 1);
|
||||||
_state.files.splice(targetIdx, 0, moved);
|
const insertAt = srcIdx < targetIdx ? targetIdx - 1 : targetIdx;
|
||||||
|
_state.files.splice(insertAt, 0, moved);
|
||||||
|
|
||||||
// 플레이스홀더 제거 후 소스 카드 복원
|
|
||||||
if (_placeholder.parentNode) _placeholder.parentNode.removeChild(_placeholder);
|
if (_placeholder.parentNode) _placeholder.parentNode.removeChild(_placeholder);
|
||||||
const srcCard = _getCardEl(srcIdx);
|
const srcCard = _getCardEl(srcIdx);
|
||||||
const targetCard = _getCardEl(targetIdx);
|
const targetCard = _getCardEl(targetIdx);
|
||||||
@@ -253,11 +247,7 @@ function _moveSingle(srcIdx, targetIdx) {
|
|||||||
|
|
||||||
if (srcCard) {
|
if (srcCard) {
|
||||||
if (targetCard) {
|
if (targetCard) {
|
||||||
if (srcIdx < targetIdx) {
|
_grid.insertBefore(srcCard, targetCard);
|
||||||
_grid.insertBefore(srcCard, targetCard.nextSibling);
|
|
||||||
} else {
|
|
||||||
_grid.insertBefore(srcCard, targetCard);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
_grid.appendChild(srcCard);
|
_grid.appendChild(srcCard);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user