Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SSIWB2504
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
SSIWB2504
Commits
61b9b1a3
Commit
61b9b1a3
authored
Aug 04, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
滚动列表完成
parent
1f40bad1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
24 deletions
+10
-24
play.component.ts
src/app/play/play.component.ts
+10
-24
No files found.
src/app/play/play.component.ts
View file @
61b9b1a3
...
...
@@ -400,7 +400,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// X坐标:从左到右排列,考虑间距,基于listItem的左边界
const
itemX
=
listItem
.
ref
.
x
+
(
column
*
(
itemWidth
+
itemSpacing
))
+
(
itemWidth
/
2
);
// Y坐标:从上到下排列,考虑间距,基于listItem的中心
const
itemY
=
listItem
.
ref
.
y
+
(
row
*
(
itemHeight
+
itemSpacing
))
+
(
itemHeight
/
2
)
-
(
listHeight
/
2
);
const
itemY
=
(
row
*
(
itemHeight
+
itemSpacing
))
+
(
itemHeight
/
2
)
-
(
listHeight
/
2
);
// 设置子节点位置和缩放
itemNode
.
ref
.
x
=
itemX
;
...
...
@@ -416,8 +416,8 @@ export class PlayComponent implements OnInit, OnDestroy {
textElement
.
ref
.
fontSize
=
80
*
this
.
g_mapScale
;
textElement
.
ref
.
fontColor
=
'
#000000
'
;
// 设置文字位置与itemNode相同
textElement
.
ref
.
x
=
itemX
;
textElement
.
ref
.
y
=
itemY
;
textElement
.
ref
.
x
=
0
//
itemX;
textElement
.
ref
.
y
=
0
//
itemY;
// 设置文本对齐方式为居中
textElement
.
ref
.
textAlign
=
'
center
'
;
...
...
@@ -431,8 +431,10 @@ export class PlayComponent implements OnInit, OnDestroy {
};
// 渲染子节点和文字
this
.
render
(
itemNode
.
ref
,
zIndexMap
.
card
);
this
.
render
(
textElement
.
ref
,
zIndexMap
.
card
+
1
);
itemNode
.
ref
.
addChild
(
textElement
.
ref
)
listItem
.
ref
.
addChild
(
itemNode
.
ref
);
// this.render(itemNode.ref, zIndexMap.card);
// this.render(textElement.ref, zIndexMap.card + 1);
}
// 添加滑动功能
...
...
@@ -472,29 +474,13 @@ export class PlayComponent implements OnInit, OnDestroy {
let
newX
=
listItemStartX
+
deltaX
;
// 限制滑动范围,防止滑出边界 - 基于左锚点的边界计算
const
minX
=
0
;
// 左边界:列表左边缘不能超出画布左边
const
maxX
=
this
.
g_canvasWidth
-
listWidth
;
// 右边界:列表右边缘不能超出画布右边
const
minX
=
this
.
g_canvasWidth
-
listWidth
;
// 左边界:列表左边缘不能超出画布左边
const
maxX
=
0
;
// 右边界:列表右边缘不能超出画布右边
newX
=
Math
.
max
(
minX
,
Math
.
min
(
newX
,
maxX
));
// 更新list_item位置
listItem
.
ref
.
x
=
newX
;
// 更新所有子节点位置 - 基于新的listItem位置重新计算
for
(
let
i
=
0
;
i
<
totalItems
;
i
++
)
{
const
column
=
Math
.
floor
(
i
/
maxItemsPerColumn
);
const
row
=
i
%
maxItemsPerColumn
;
const
itemNode
=
this
.
g_cartoon
.
getCartoonElement
(
`list_item_
${
i
}
`
);
const
textElement
=
this
.
g_cartoon
.
getCartoonElement
(
`list_item_text_
${
i
}
`
);
if
(
itemNode
)
{
const
itemX
=
listItem
.
ref
.
x
+
(
column
*
(
itemWidth
+
itemSpacing
))
+
(
itemWidth
/
2
);
itemNode
.
ref
.
x
=
itemX
;
// 同时更新对应的文字位置
if
(
textElement
)
{
textElement
.
ref
.
x
=
itemX
;
}
}
}
console
.
log
(
"
listItem.ref.x
"
,
listItem
.
ref
.
x
)
}
// 重新启用移动事件
this
.
g_enableMapMove
=
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment