tdesign-mobile-vue
Version:
tdesign-mobile-vue
1 lines • 1.26 kB
Source Map (JSON)
{"version":3,"file":"swapDragArrayElement.mjs","sources":["../../../../src/_common/js/utils/swapDragArrayElement.ts"],"sourcesContent":["// 拖拽排序场景中:调整某个元素的顺序\nexport default function swapDragArrayElement(\n data: any[], currentIndex: number, targetIndex: number\n) {\n const newData = [...data];\n if (targetIndex - currentIndex > 0) {\n newData.splice(targetIndex + 1, 0, newData[currentIndex]);\n newData.splice(currentIndex, 1);\n } else {\n newData.splice(targetIndex, 0, newData[currentIndex]);\n newData.splice(currentIndex + 1, 1);\n }\n return newData;\n}\n"],"names":["swapDragArrayElement","data","currentIndex","targetIndex","newData","_toConsumableArray","splice"],"mappings":";;;;;;;;;AACwB,SAAAA,oBAAAA,CACtBC,IAAa,EAAAC,YAAA,EAAsBC,WACnC,EAAA;AACM,EAAA,IAAAC,OAAA,GAAAC,kBAAA,CAAcJ,IAAI,CAAA,CAAA;AACpB,EAAA,IAAAE,WAAA,GAAcD,eAAe,CAAG,EAAA;AAClCE,IAAAA,OAAA,CAAQE,MAAO,CAAAH,WAAA,GAAc,CAAG,EAAA,CAAA,EAAGC,QAAQF,YAAa,CAAA,CAAA,CAAA;AAChDE,IAAAA,OAAA,CAAAE,MAAA,CAAOJ,cAAc,CAAC,CAAA,CAAA;AAChC,GAAO,MAAA;IACLE,OAAA,CAAQE,MAAO,CAAAH,WAAA,EAAa,CAAG,EAAAC,OAAA,CAAQF,YAAa,CAAA,CAAA,CAAA;IAC5CE,OAAA,CAAAE,MAAA,CAAOJ,YAAe,GAAA,CAAA,EAAG,CAAC,CAAA,CAAA;AACpC,GAAA;AACO,EAAA,OAAAE,OAAA,CAAA;AACT;;;;"}