insertPage说明是将页面插入到指定位置中,但实际体验是删除指定位置的页面,然后在末尾添加一个新页面,并不能在指定位置添加.这个问题如果真的有的话,应该很容易就能发现,感觉没什么人提到
前排插入会导致PageView的滚动出现问题,视觉反馈会给人感觉插入位置错误。
目前我是通过调整PageView的内部变量来绕过问题。
这是我的代码,我的使用场景是只有最前排插入(insertFront = true)和最后排插入两种情况。
引擎版本 2.4.2
你可以试试insertPage到其他位置。
let oldPageIndex = mapPageView.getCurrentPageIndex();
if (insertFront) {
mapPageView.insertPage(page, 0);
} else {
mapPageView.addPage(page);
}
// ...
if (insertFront) {
mapPageView.scrollToPage(oldPageIndex + 1, 0); // 前方插入后pageIndex后移
//@ts-ignore workaround bug: 前排插入新页后滑动不触发page-turning
mapPageView._lastPageIdx = mapPageView._curPageIdx;
if (mapPageView.isAutoScrolling()) {
//@ts-ignore workaround,前排插入页面时需要调整内部变量的滑动起始点
mapPageView._autoScrollStartPosition.x -= page.width;
}
}
大佬nb,确实可以实现了
,我也只需要前后循环,实现循环pageview
该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。