PageView连续快速滑动,会停住不动了。
PageEvent也不会触发
附图:
合并了还是一样,并不是这个修复的问题
因为这类问题不好做复现的demo,可否提供个demo?
很好复现,就拿官方例子工程的PageView场景就可以重现,好像只有第二页切回第一页才会触发这个BUG,快速连续两次滑动。
我解决了
修改了engine/cocos2d/core/components/CCPageView.js的代码,如下注释部分:
_handleReleaseLogic: function(touch) {
var bounceBackStarted = this._startBounceBackIfNeeded();
var moveOffset = cc.pSub(this._touchBeganPosition, this._touchEndPosition);
if (bounceBackStarted) {
var dragDirection = this._getDragDirection(moveOffset);
if (dragDirection === 0) {
return;
}
if (dragDirection > 0) {
this._curPageIdx = this._pages.length - 1;
}
else {
this._curPageIdx = 0;
}
if (this.indicator) {
this.indicator._changedState();
}
}
else {
var index = this._curPageIdx, nextIndex = index + this._getDragDirection(moveOffset);
var timeInSecond = this.pageTurningSpeed * Math.abs(index - nextIndex);
if (nextIndex >= 0 && nextIndex < this._pages.length) { // 增加判断切页的页码是否大于等于0
if (this._isScrollable(moveOffset, index, nextIndex)) {
this.scrollToPage(nextIndex, timeInSecond);
return;
}
else {
var touchMoveVelocity = this._calculateTouchMoveVelocity();
if (this._isQuicklyScrollable(touchMoveVelocity)) {
this.scrollToPage(nextIndex, timeInSecond);
return;
}
}
}
this.scrollToPage(index, timeInSecond);
}
}