|
@@ -407,6 +407,8 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
|
|
|
var toIndexOffset: Int = 0
|
|
|
// 需要移动的页面index数组
|
|
|
var newPages: [CPDFPage] = []
|
|
|
+ var currentPage: CPDFPage?
|
|
|
+ var originalIndex = self.listViewCurrentIndex
|
|
|
// 从后面往前删除
|
|
|
for index in indexs.reversed() {
|
|
|
let newPage = (self.listView?.document.page(at: UInt(index)))?.copy() as? CPDFPage
|
|
@@ -418,6 +420,9 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
|
|
|
if (index < toIndex) { /// 删除了插入位置前面的页面,需要改变 toIndex
|
|
|
toIndexOffset += 1
|
|
|
}
|
|
|
+ if (currentPage == nil) && (originalIndex == index) {
|
|
|
+ currentPage = newPage
|
|
|
+ }
|
|
|
}
|
|
|
if (indexs.last! < toIndex) { // 往后拖拽
|
|
|
toIndexOffset -= 1
|
|
@@ -427,6 +432,9 @@ class KMPDFEditViewController: KMPDFThumbViewBaseController {
|
|
|
for (index, page) in newPages.enumerated() {
|
|
|
self.listView?.document.insertPageObject(page, at: UInt(insertIndex+index))
|
|
|
selectIndexs.insert(insertIndex+index)
|
|
|
+ if (currentPage?.pageIndex() == page.pageIndex()) {
|
|
|
+ self._listViewCurrentIndex = insertIndex+index
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 新增 undo
|
|
@@ -1081,7 +1089,7 @@ extension KMPDFEditViewController {
|
|
|
toIndexOffset -= 1
|
|
|
}
|
|
|
let insertIndex = max(0, toIndex-toIndexOffset)
|
|
|
- self._listViewCurrentIndex = insertIndex+idx
|
|
|
+// self._listViewCurrentIndex = insertIndex+idx
|
|
|
}
|
|
|
}
|
|
|
}
|