Commit 8a9ca99c authored by Tt's avatar Tt

fix: 调整滚动触发条件从5个改为4个未回答题目

parent 4986a39a
......@@ -5980,7 +5980,7 @@
"__id__": 145
}
],
"_active": false,
"_active": true,
"_components": [],
"_prefab": null,
"_opacity": 255,
......
......@@ -311,10 +311,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 重置滚动状态
this.layout.x = 0;
this.scrollDistance = 0;
this.needScroll = unansweredQuestions.length > 5; // 如果有超过5个未回答题目,启用滚动
this.needScroll = unansweredQuestions.length > 4; // 如果有超过4个未回答题目,启用滚动
// 初始化数据队列
const initialVisibleCount = Math.min(5, unansweredQuestions.length);
// 如果剩余题目小于等于4个,显示所有剩余题目;否则显示5个
const initialVisibleCount = unansweredQuestions.length <= 4 ? unansweredQuestions.length : Math.min(5, unansweredQuestions.length);
const visibleData = unansweredQuestions.slice(0, initialVisibleCount);
this.pendingCandyData = unansweredQuestions.slice(initialVisibleCount);
......@@ -352,8 +353,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
return;
}
// 如果未回答题目数量小于5,停止滚动并重新刷新列表
if (unansweredQuestions.length < 5) {
// 如果未回答题目数量小于等于4,停止滚动并重新刷新列表
if (unansweredQuestions.length <= 4) {
this.needScroll = false; // 停止滚动
// 重新显示页面
this.showPage();
......@@ -375,7 +376,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.activeNodes.push(candyNode);
// 如果有足够的节点,启用滚动
if (this.activeNodes.length > 5) {
if (this.activeNodes.length > 4) {
this.needScroll = true;
}
}
......@@ -533,8 +534,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
return;
}
// 如果未回答题目数量小于5,设置不滚动
if (unansweredQuestions.length < 5) {
// 如果未回答题目数量小于等于4,设置不滚动
if (unansweredQuestions.length <= 4) {
this.needScroll = false;
}
......@@ -850,7 +851,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
// 更新滚动状态,根据剩余未回答题目数量决定是否继续滚动
this.needScroll = this.activeNodes.length > 5 || this.pendingCandyData.length > 0;
this.needScroll = this.activeNodes.length > 4 || this.pendingCandyData.length > 0;
}
/**
......@@ -897,6 +898,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
} else {
if (this.pendingCandyData.length == 0) {
let unansweredQuestions = this.getUnansweredQuestions();
// 如果未回答题目数量小于等于4,停止滚动并重新刷新列表
if (unansweredQuestions.length <= 4) {
this.needScroll = false; // 停止滚动
this.showPage(); // 重新显示页面
return;
}
this.pendingCandyData = unansweredQuestions.concat();
}
this.addCount++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment