|
@@ -540,7 +540,7 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
|
|
|
self.listView?.document.insertPageObject(page, at: UInt(insertIndex+index))
|
|
|
selectIndexs.insert(insertIndex+index)
|
|
|
if (currentPage?.pageIndex() == page.pageIndex()) {
|
|
|
- self._listViewCurrentIndex = insertIndex+index
|
|
|
+// self._listViewCurrentIndex = insertIndex+index
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1103,6 +1103,9 @@ extension KMPDFEditViewController {
|
|
|
}
|
|
|
|
|
|
func listViewCurrentPageUpdateForDrag(indexs: IndexSet, toIndex: Int) {
|
|
|
+ if (indexs.isEmpty) {
|
|
|
+ return
|
|
|
+ }
|
|
|
// listView 当前页面 被拖拽
|
|
|
if (indexs.contains(self._listViewCurrentIndex)) {
|
|
|
// let idx = indexs.firstIndex(of: self._listViewCurrentIndex)
|
|
@@ -1130,7 +1133,25 @@ extension KMPDFEditViewController {
|
|
|
toIndexOffset -= 1
|
|
|
}
|
|
|
let insertIndex = max(0, toIndex-toIndexOffset)
|
|
|
-// self._listViewCurrentIndex = insertIndex+idx
|
|
|
+ self._listViewCurrentIndex = insertIndex+idx
|
|
|
+ } else {
|
|
|
+ var forwardCnt = 0
|
|
|
+ var nextCnt = 0
|
|
|
+ for index in indexs {
|
|
|
+ if (index > self._listViewCurrentIndex) {
|
|
|
+ nextCnt += 1
|
|
|
+ } else {
|
|
|
+ forwardCnt += 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (self._listViewCurrentIndex > toIndex) { // 插入到目标前面, 前面不管,只管后面的格式
|
|
|
+ self._listViewCurrentIndex += nextCnt
|
|
|
+ } else if (self._listViewCurrentIndex < toIndex) { // 插入到目标后面, 后面不管,只管前面的格式
|
|
|
+ self._listViewCurrentIndex = max(0, self._listViewCurrentIndex - forwardCnt)
|
|
|
+ } else { // 插入到目标位置 [跟插入到目标后面一样]
|
|
|
+ self._listViewCurrentIndex = max(0, self._listViewCurrentIndex - forwardCnt)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|