@shijiu/jsview-vue-samples 2.3.151-test.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ABImageAlt/App.vue +114 -0
- package/ABImageAlt/Item.vue +133 -0
- package/{MetroWidgetDemos/SkeletonDiagram/assets/imageList.json → ABImageAlt/assets/imageList.js} +9 -1
- package/ABImageAlt/data.js +17 -0
- package/AI_Check_Rules.txt +5 -0
- package/AnimPicture/App.vue +20 -10
- package/ApicSwitch/App.vue +90 -0
- package/ApicSwitch/TabItem.vue +65 -0
- package/ApicSwitch/WebpShow.vue +24 -0
- package/ApicSwitch/data.js +50 -0
- package/Basic/AI_skills_update.md +1 -0
- package/Basic/components/div/ColorFormatTest.vue +93 -0
- package/Basic/components/div/DivRadius.vue +97 -15
- package/Basic/components/div/DivTag3Group.vue +30 -0
- package/Basic/components/img/ImageType.vue +65 -0
- package/Basic/components/panel/Panel2.vue +13 -1
- package/Basic/components/text/TextAlign.vue +7 -1
- package/BlobLoadTest/App.vue +201 -0
- package/BreakLinesApi/App.vue +82 -0
- package/CanvasDrawChart/App.vue +11 -0
- package/CanvasDrawChart/Graph1.vue +104 -0
- package/CanvasDrawChart/Graph2.vue +115 -0
- package/CssPreprocessor/Scss/PanelData.js +1 -1
- package/CssPreprocessor/Scss/components/scss-group4/ScssMaps.vue +4 -3
- package/CssPreprocessor/Scss/components/scss-group5/ScssImporting.vue +2 -2
- package/DemoForOperator/Bounce/FreeMoveBuilder.js +1 -1
- package/DemoForOperator/Firework1/App.vue +12 -1
- package/DemoForOperator/Firework1/Fireworks.vue +18 -0
- package/DemoForOperator/FlipPage/FlipPage/FlipPage.vue +1 -0
- package/DemoForOperator/Focus/Alpha/Item.vue +1 -0
- package/DemoForOperator/Focus/Light/Item.vue +1 -0
- package/DemoForOperator/Focus/Normal/Item.vue +1 -0
- package/DemoForOperator/FrameShadow/FrameShadow.vue +1 -1
- package/DemoForOperator/Genie/App.vue +20 -6
- package/DemoForOperator/Genie/App2.vue +61 -0
- package/DemoForOperator/Genie/geniePakcer/GenieImage.vue +298 -0
- package/DemoForOperator/Genie/geniePakcer/GenieSlot.vue +292 -0
- package/DemoForOperator/Genie/geniePakcer/GenieTools.ts +463 -0
- package/DemoForOperator/Jigsaw/JigsawFull.vue +12 -7
- package/DemoForOperator/Jigsaw/JigsawSingle.vue +13 -7
- package/DemoForOperator/LongChatBox/App.vue +13 -13
- package/DemoForOperator/LongChatBox/Bubble.vue +78 -66
- package/DemoForOperator/LongChatBox/LongChat.vue +68 -36
- package/DemoForOperator/LongChatBox/testData.js +7 -44
- package/DemoForOperator/Sound/Bounce/FreeMoveBuilder.js +1 -1
- package/DemoForOperator/routeList.js +8 -2
- package/DemoHomepage/App.vue +74 -1
- package/DemoHomepage/components/BodyFrame.vue +1 -0
- package/DemoHomepage/components/TabFrame.vue +1 -1
- package/DemoHomepage/router.js +723 -160
- package/DemoHomepage/views/Homepage.vue +60 -2
- package/DemoHomepage/watchTest.vue +50 -0
- package/FilterDemo/AnimatePic.vue +63 -17
- package/FilterDemo/App.vue +3 -3
- package/FlexCellDemo/AI_skills_update.md +4 -0
- package/FlexCellDemo/TestFrame1.vue +12 -2
- package/FlexCellDemo/TestFrame2.vue +10 -1
- package/FlexCellDemo/TestFrame3.vue +114 -59
- package/FpsLimit/App.vue +102 -0
- package/FreeMoveChildAttract/App.vue +18 -8
- package/FreeMoveLink/App.vue +49 -20
- package/Hover/App.vue +144 -0
- package/HttpRequestSSE/SSEReader.js +200 -0
- package/ImpactStop/App.vue +2 -2
- package/Input/FullKeyboard.vue +3 -3
- package/Input/InputPanel.vue +63 -3
- package/JsvLine/App.vue +53 -38
- package/LatexDemo/App.vue +3 -1
- package/LatexFormula/App.vue +196 -0
- package/LongImage/App.vue +1 -1
- package/LongImage/LongImageScroll.vue +100 -47
- package/LongImage/Scroll.vue +28 -9
- package/LongText/LongTextScroll.vue +1 -0
- package/Markdown/App.vue +36 -0
- package/Markdown/Bubble.vue +109 -0
- package/Markdown/LongChat.vue +206 -0
- package/Markdown/Markdown/Markdown.vue +156 -0
- package/Markdown/Markdown/index.ts +1 -0
- package/Markdown/Markdown/marked/LICENSE.md +45 -0
- package/Markdown/Markdown/marked/index.ts +2 -0
- package/Markdown/Markdown/marked/marked.d.ts +756 -0
- package/Markdown/Markdown/marked/marked.js +71 -0
- package/Markdown/Markdown/parser.ts +1365 -0
- package/Markdown/data.js +581 -0
- package/MetroWidgetDemos/AI_skills_update.md +2 -0
- package/MetroWidgetDemos/ListExpand/ChildItem.vue +130 -0
- package/MetroWidgetDemos/ListExpand/ExpandItem.vue +375 -0
- package/MetroWidgetDemos/ListExpand/ExpandItem1.vue +403 -0
- package/MetroWidgetDemos/ListExpand/assets/arrow-down.png +0 -0
- package/MetroWidgetDemos/ListExpand/assets/up-arrow.png +0 -0
- package/MetroWidgetDemos/ListExpand/components/WidgetListHandler.vue +150 -0
- package/MetroWidgetDemos/ListExpand/index.vue +88 -0
- package/MetroWidgetDemos/ListExpand/list.js +2421 -0
- package/MetroWidgetDemos/RefreshDemo/App.vue +14 -1
- package/MetroWidgetDemos/RenderAccelerate/App.vue +142 -0
- package/MetroWidgetDemos/RenderAccelerate/AppPage.vue +78 -0
- package/MetroWidgetDemos/RenderAccelerate/AppTab.vue +62 -0
- package/MetroWidgetDemos/RenderAccelerate/ContentItem.vue +409 -0
- package/MetroWidgetDemos/RenderAccelerate/Item.vue +67 -0
- package/MetroWidgetDemos/RenderAccelerate/TabItem.vue +100 -0
- package/MetroWidgetDemos/RenderAccelerate/ViewSwiper.vue +215 -0
- package/MetroWidgetDemos/RenderAccelerate/WidgetItem.vue +107 -0
- package/MetroWidgetDemos/SkeletonDiagram/App.vue +35 -8
- package/MetroWidgetDemos/SkeletonDiagram/Item.vue +11 -2
- package/MetroWidgetDemos/SkeletonDiagram/assets/imageList.js +245 -0
- package/MetroWidgetDemos/SkeletonDiagram/data.js +3 -3
- package/MetroWidgetDemos/SpatialNav/App.vue +177 -0
- package/MetroWidgetDemos/SpatialNav/Buttons.vue +83 -0
- package/MetroWidgetDemos/SpatialNav/CustomFocus.vue +57 -0
- package/MetroWidgetDemos/{TripleWidget → SpatialNav}/Item.vue +1 -8
- package/MetroWidgetDemos/{TripleWidget/WidgetItem.vue → SpatialNav/SimpleFloor.vue} +14 -45
- package/MetroWidgetDemos/SpatialNav/StepMw.vue +113 -0
- package/MetroWidgetDemos/SpatialNav/TabContent/TabContent.vue +185 -0
- package/MetroWidgetDemos/SpatialNav/TripleSection/TripleSection.vue +69 -0
- package/MetroWidgetDemos/SpatialNav/TripleSection/WidgetItem.vue +100 -0
- package/MetroWidgetDemos/SpatialNav/TvSection/List.vue +75 -0
- package/MetroWidgetDemos/SpatialNav/TvSection/TvSection.vue +91 -0
- package/MetroWidgetDemos/basic2/App.vue +407 -0
- package/MetroWidgetDemos/basic2/Item.vue +68 -0
- package/MetroWidgetDemos/direction/App.vue +22 -0
- package/MetroWidgetDemos/gazeFocusDiff/App.vue +126 -0
- package/MetroWidgetDemos/gazeFocusDiff/Item.vue +87 -0
- package/MetroWidgetDemos/minimalUsage/App.vue +66 -0
- package/MetroWidgetDemos/minimalUsage/Item.vue +54 -0
- package/MetroWidgetDemos/ninePatchFocusPage/App.vue +22 -7
- package/MetroWidgetDemos/ninePatchFocusPage/Item.vue +7 -5
- package/MetroWidgetDemos/ninePatchFocusPage/focusConstants.js +2 -0
- package/MetroWidgetDemos/routeList.js +203 -12
- package/MetroWidgetDemos/slideSetting/App.vue +288 -99
- package/MetroWidgetDemos/zIndex/App.vue +117 -0
- package/MetroWidgetDemos/zIndex/Item.vue +61 -0
- package/NinePatchTester/App.vue +24 -31
- package/PreDecode/App.vue +140 -0
- package/ReactiveTest/App.vue +115 -0
- package/ReactiveTest/Item.vue +92 -0
- package/ReactiveTest/assets/imageList.js +245 -0
- package/ReactiveTest/component/TestSmartDiv.vue +50 -0
- package/ReactiveTest/component/TestSmartDivSrcList.vue +74 -0
- package/ReactiveTest/component/TestSmartImage.vue +46 -0
- package/ReactiveTest/component/TestSmartImageSrcList.vue +90 -0
- package/ReactiveTest/component/TestSmartImageStyle.vue +41 -0
- package/ReactiveTest/data.js +49 -0
- package/ScreenToBlob/App.vue +250 -0
- package/SecTorTest/App.vue +9 -3
- package/SpringFestival/SpringFestivalScene/FreeMoveBuilder.js +3 -3
- package/SyncDecode/App.vue +137 -0
- package/TextSizeLimit/App.vue +211 -0
- package/TransitPage/App.vue +2 -0
- package/assets/logo.png +0 -0
- package/package.json +5 -5
- package/DemoForOperator/Genie/geniePakcer/Genie.vue +0 -741
- package/DemoForOperator/LongChatBox/TextManager.ts +0 -147
- package/DemoForOperator/LongChatBox/VirtualList.vue +0 -298
- package/DemoForOperator/LongChatBox/utile.js +0 -331
- package/DivMetroPerformance/App.vue +0 -157
- package/DivMetroPerformance/Item.vue +0 -58
- package/DivMetroPerformance/assets/bg.jpg +0 -0
- package/DivMetroPerformance/assets/coupon_content.png +0 -0
- package/DivMetroPerformance/assets/coupon_left.png +0 -0
- package/DivMetroPerformance/assets/coupon_mid.png +0 -0
- package/DivMetroPerformance/assets/coupon_right.png +0 -0
- package/DivMetroPerformance/assets/focus_border.png +0 -0
- package/DivMetroPerformance/assets/holder_logo.png +0 -0
- package/DivMetroPerformance/assets/jrbm.png +0 -0
- package/DivMetroPerformance/assets/line_left.png +0 -0
- package/DivMetroPerformance/assets/line_mid.png +0 -0
- package/DivMetroPerformance/assets/line_right.png +0 -0
- package/DivMetroPerformance/assets/loading.png +0 -0
- package/DivMetroPerformance/assets/logo.png +0 -0
- package/DivMetroPerformance/assets/mcjx.png +0 -0
- package/DivMetroPerformance/assets/tao.png +0 -0
- package/DivMetroPerformance/assets/tmall.png +0 -0
- package/DivMetroPerformance/border.png +0 -0
- package/DivMetroPerformance/components/ContentItem.vue +0 -384
- package/DivMetroPerformance/components/MyTab.vue +0 -129
- package/DivMetroPerformance/data.js +0 -124
- package/DivMetroPerformance/utils/GridItem.vue +0 -28
- package/DivMetroPerformance/utils/GridPlate.vue +0 -85
- package/MediaDemo/App.vue +0 -127
- package/MediaDemo/assets/audio-poster.png +0 -0
- package/MediaDemo/components/Button.vue +0 -69
- package/MediaDemo/components/Controllor.vue +0 -286
- package/MediaDemo/components/StatusBar.vue +0 -100
- package/MediaDemo/components/frames/AudioFrame.vue +0 -39
- package/MediaDemo/components/frames/AudioPoster.vue +0 -48
- package/MediaDemo/components/frames/MediaFrame.vue +0 -153
- package/MediaDemo/components/frames/VideoFrame.vue +0 -39
- package/MetroWidgetDemos/TripleWidget/App.vue +0 -87
- package/MetroWidgetDemos/TripleWidget/SWidgetItem.vue +0 -99
- package/Parkour/App.vue +0 -13
- package/Parkour/Common/Context.js +0 -21
- package/Parkour/Common/MatchmanInfo.js +0 -62
- package/Parkour/Common/Random.js +0 -61
- package/Parkour/Common/Sound.js +0 -50
- package/Parkour/appConfig/HOW_TO_CONFIG.md +0 -20
- package/Parkour/appConfig/app.config.mjs +0 -5
- package/Parkour/appConfig/app_sign_private_key_sample.crt +0 -28
- package/Parkour/appConfig/app_sign_public_key_sample.pem +0 -9
- package/Parkour/appConfig/jsview.config.mjs +0 -39
- package/Parkour/assets/Bgimages/bg1.png +0 -0
- package/Parkour/assets/Bgimages/bg2.png +0 -0
- package/Parkour/assets/Bgimages/bg3.png +0 -0
- package/Parkour/assets/Bgimages/bg4.png +0 -0
- package/Parkour/assets/Bgimages/bg5.png +0 -0
- package/Parkour/assets/audio/jump.mp3 +0 -0
- package/Parkour/assets/audio/lose.mp3 +0 -0
- package/Parkour/assets/role_skin1/fail.json +0 -44
- package/Parkour/assets/role_skin1/fail.png +0 -0
- package/Parkour/assets/role_skin1/jump_down.json +0 -20
- package/Parkour/assets/role_skin1/jump_down.png +0 -0
- package/Parkour/assets/role_skin1/jump_up.json +0 -44
- package/Parkour/assets/role_skin1/jump_up.png +0 -0
- package/Parkour/assets/role_skin1/roll.json +0 -44
- package/Parkour/assets/role_skin1/roll.png +0 -0
- package/Parkour/assets/role_skin1/run.json +0 -52
- package/Parkour/assets/role_skin1/run.png +0 -0
- package/Parkour/components/Backdrop.vue +0 -61
- package/Parkour/components/GameSence.vue +0 -602
- package/Parkour/components/Matchman.vue +0 -85
- package/ThrowMoveDemo/AccelerateDemo.vue +0 -85
- package/ThrowMoveDemo/App.vue +0 -104
- package/ThrowMoveDemo/LRParabolicDemo.vue +0 -101
- package/ThrowMoveDemo/TargetDemo.vue +0 -87
- package/ThrowMoveDemo/UDParabolicDemo.vue +0 -92
- /package/{AnimPicture/assets → assets}/animated_webp.webp +0 -0
- /package/{AnimPicture/assets → assets}/ball_3.webp +0 -0
- /package/{AnimPicture/assets → assets}/girl_run.gif +0 -0
- /package/{AnimPicture/assets → assets}/quan.webp +0 -0
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 处理流式文本的分行
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
TypeTransitionApi,
|
|
6
|
-
StyleTransitionApi2,
|
|
7
|
-
TextTransitionApi,
|
|
8
|
-
} from "./utile";
|
|
9
|
-
import { reactive, ref, Ref, shallowRef, ShallowRef } from "vue";
|
|
10
|
-
|
|
11
|
-
interface Rect {
|
|
12
|
-
left: number;
|
|
13
|
-
top: number;
|
|
14
|
-
width: number;
|
|
15
|
-
height: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface LineInfo {
|
|
19
|
-
type: "text" | "horizontalLine";
|
|
20
|
-
text: Ref<string>;
|
|
21
|
-
style: unknown;
|
|
22
|
-
rect: Rect;
|
|
23
|
-
lineNumber: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export class TextManager {
|
|
27
|
-
public lines: LineInfo[] = [];
|
|
28
|
-
public updatingLine: LineInfo | null = null;
|
|
29
|
-
public currentLineStyle: any = {};
|
|
30
|
-
private textWidth: number = 0;
|
|
31
|
-
private onAddLine: Function = (line: LineInfo) => {};
|
|
32
|
-
private onLineUpdatDone: Function = (line: LineInfo) => {};
|
|
33
|
-
private onLineUpdate: Function = (line: LineInfo) => {};
|
|
34
|
-
|
|
35
|
-
constructor(
|
|
36
|
-
textWidth: number,
|
|
37
|
-
onAddLine: (line: LineInfo) => void,
|
|
38
|
-
onLineUpdate: (line: LineInfo) => void,
|
|
39
|
-
onLineUpdatDone: (line: LineInfo) => void,
|
|
40
|
-
) {
|
|
41
|
-
this.textWidth = textWidth;
|
|
42
|
-
this.onAddLine = onAddLine;
|
|
43
|
-
this.onLineUpdatDone = onLineUpdatDone;
|
|
44
|
-
this.onLineUpdate = onLineUpdate;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public addText(textSlice: string, textRef: Ref<string>) {
|
|
48
|
-
if (!this.updatingLine) {
|
|
49
|
-
const type = TypeTransitionApi(textSlice);
|
|
50
|
-
this.currentLineStyle = StyleTransitionApi2(textSlice);
|
|
51
|
-
let left = 0,
|
|
52
|
-
top = 0;
|
|
53
|
-
if (this.lines.length > 0) {
|
|
54
|
-
const lastLine = this.lines[this.lines.length - 1];
|
|
55
|
-
left = lastLine.rect.left;
|
|
56
|
-
top = lastLine.rect.top + lastLine.rect.height;
|
|
57
|
-
}
|
|
58
|
-
this.updatingLine = this.newLine();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// 检查是否有换行符
|
|
62
|
-
if (textSlice.match(/(\r\n|\n|\r)/)) {
|
|
63
|
-
// 将文本按换行符分割
|
|
64
|
-
const parts = textSlice.split(/(\r\n|\n|\r)/);
|
|
65
|
-
// 只处理第一部分(换行符之前的内容)
|
|
66
|
-
if (parts.length > 0 && parts[0]) {
|
|
67
|
-
this.updatingLine.text.value += parts[0];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// 完成当前行并添加到lines数组
|
|
71
|
-
this.commitLine();
|
|
72
|
-
|
|
73
|
-
// 如果换行符后还有内容,为下一行创建新的行对象
|
|
74
|
-
if (parts.length > 2 && parts[2]) {
|
|
75
|
-
const nextType = TypeTransitionApi(parts[2]);
|
|
76
|
-
const nextStyle = StyleTransitionApi2(parts[2]);
|
|
77
|
-
|
|
78
|
-
this.updatingLine = this.newLine(parts[2]);
|
|
79
|
-
} else {
|
|
80
|
-
// 如果换行符后没有内容,将updatingLine设为null,等待下一次addText调用
|
|
81
|
-
this.updatingLine = null;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
textRef.value = this.updatingLine?.text.value ?? "";
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
// 没有换行符,直接添加到当前行
|
|
88
|
-
this.updatingLine.text.value += textSlice;
|
|
89
|
-
if (this.updatingLine.text.value.length > 33) {
|
|
90
|
-
const preText = this.updatingLine.text.value.slice(0, 33);
|
|
91
|
-
const nextText = this.updatingLine.text.value.slice(33);
|
|
92
|
-
this.updatingLine.text.value = preText;
|
|
93
|
-
this.commitLine();
|
|
94
|
-
this.updatingLine = this.newLine(nextText);
|
|
95
|
-
} else {
|
|
96
|
-
this.onLineUpdate(this.updatingLine);
|
|
97
|
-
}
|
|
98
|
-
textRef.value = this.updatingLine?.text.value ?? "";
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
public stopUpdateLineManually() {
|
|
102
|
-
if (this.updatingLine) {
|
|
103
|
-
this.commitLine();
|
|
104
|
-
this.updatingLine = null;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public updateLineHeight(height: number) {
|
|
109
|
-
if (this.updatingLine) {
|
|
110
|
-
console.log(
|
|
111
|
-
"ccht updateLineHeight",
|
|
112
|
-
this.updatingLine.lineNumber,
|
|
113
|
-
height
|
|
114
|
-
);
|
|
115
|
-
this.updatingLine.rect.height = height;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
private commitLine() {
|
|
120
|
-
if (this.updatingLine) {
|
|
121
|
-
//做 markdown 的替换
|
|
122
|
-
this.updatingLine.text.value = TextTransitionApi(
|
|
123
|
-
this.updatingLine.text.value
|
|
124
|
-
);
|
|
125
|
-
this.lines.push(this.updatingLine);
|
|
126
|
-
this.updatingLine = null;
|
|
127
|
-
this.onLineUpdatDone(this.lines[this.lines.length - 1]);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
private newLine(text: string = "") {
|
|
132
|
-
const line = {
|
|
133
|
-
type: "text" as const,
|
|
134
|
-
text: ref(text),
|
|
135
|
-
style: this.currentLineStyle,
|
|
136
|
-
rect: {
|
|
137
|
-
left: 0,
|
|
138
|
-
top: 0,
|
|
139
|
-
width: 0,
|
|
140
|
-
height: 0,
|
|
141
|
-
},
|
|
142
|
-
lineNumber: this.lines.length,
|
|
143
|
-
};
|
|
144
|
-
this.onAddLine(line);
|
|
145
|
-
return line;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
/**
|
|
3
|
-
* 虚拟列表, 超出可以范围的元素会被隐藏
|
|
4
|
-
*/
|
|
5
|
-
let IdToken = 0;
|
|
6
|
-
</script>
|
|
7
|
-
<script setup>
|
|
8
|
-
import { JsvFlexDiv } from "jsview";
|
|
9
|
-
import { ref, shallowRef, reactive, computed } from "vue";
|
|
10
|
-
|
|
11
|
-
const emit = defineEmits(["sizechange"]);
|
|
12
|
-
|
|
13
|
-
const props = defineProps({
|
|
14
|
-
layout: {
|
|
15
|
-
type: Object,
|
|
16
|
-
default: () => ({
|
|
17
|
-
width: 0,
|
|
18
|
-
height: 0,
|
|
19
|
-
left: 0,
|
|
20
|
-
top: 0,
|
|
21
|
-
}),
|
|
22
|
-
},
|
|
23
|
-
initVisibleStart: {
|
|
24
|
-
type: Number,
|
|
25
|
-
default: 0,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
const renderList = reactive([]);
|
|
29
|
-
const visibleStart = ref(props.initVisibleStart);
|
|
30
|
-
const totalContentWidth = ref(props.layout.width);
|
|
31
|
-
const totalContentHeight = ref(0);
|
|
32
|
-
let isVisible = true;
|
|
33
|
-
//默认自动显示最后一行, 外部调用 slideTo 后不再自动移动
|
|
34
|
-
let enableAutoSlide = true;
|
|
35
|
-
let itemList = [];
|
|
36
|
-
|
|
37
|
-
class ItemInfo {
|
|
38
|
-
constructor(customKey, id, customData, tmpTop) {
|
|
39
|
-
this.id = id;
|
|
40
|
-
this.customKey = customKey;
|
|
41
|
-
this.layout = {
|
|
42
|
-
left: 0,
|
|
43
|
-
top: tmpTop,
|
|
44
|
-
width: 0,
|
|
45
|
-
height: 0,
|
|
46
|
-
};
|
|
47
|
-
this.data = customData;
|
|
48
|
-
this.onSize = this._onSize.bind(this);
|
|
49
|
-
this.done = this._done.bind(this);
|
|
50
|
-
this._onSizeCalled = false;
|
|
51
|
-
this._updateDone = false;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
_onSize(width, height) {
|
|
55
|
-
this.layout.width = width;
|
|
56
|
-
this.layout.height = height;
|
|
57
|
-
onItemSizeUpdate(this.id);
|
|
58
|
-
updateRenderList();
|
|
59
|
-
this._onSizeCalled = true;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
_done() {
|
|
63
|
-
this._updateDone = true;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
isStatic() {
|
|
67
|
-
return this._updateDone && this._onSizeCalled;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function onItemSizeUpdate(id) {
|
|
72
|
-
//更新itemlayout
|
|
73
|
-
let start = 0;
|
|
74
|
-
for (let i = 0; i < itemList.length; i++) {
|
|
75
|
-
const item = itemList[i];
|
|
76
|
-
if (item.id >= id) {
|
|
77
|
-
item.layout.top = start;
|
|
78
|
-
}
|
|
79
|
-
start += item.layout.height;
|
|
80
|
-
}
|
|
81
|
-
totalContentHeight.value = start;
|
|
82
|
-
emit("sizechange", totalContentHeight.value);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const EXTRA_RECT = 100;
|
|
86
|
-
function updateRenderList() {
|
|
87
|
-
renderList.splice(0);
|
|
88
|
-
if (!isVisible) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
if (enableAutoSlide) {
|
|
92
|
-
let h = 0;
|
|
93
|
-
for (let i = itemList.length - 1; i >= 0; --i) {
|
|
94
|
-
const item = itemList[i];
|
|
95
|
-
renderList.unshift(item);
|
|
96
|
-
h += item.layout.height;
|
|
97
|
-
if (h >= props.layout.height + EXTRA_RECT) {
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
visibleStart.value = Math.max(
|
|
102
|
-
totalContentHeight.value - props.layout.height,
|
|
103
|
-
0
|
|
104
|
-
);
|
|
105
|
-
} else {
|
|
106
|
-
for (let i = 0; i < itemList.length; i++) {
|
|
107
|
-
const item = itemList[i];
|
|
108
|
-
if (
|
|
109
|
-
(item.layout.top + item.layout.height >=
|
|
110
|
-
visibleStart.value - EXTRA_RECT &&
|
|
111
|
-
item.layout.top <= visibleStart.value + props.layout.height) ||
|
|
112
|
-
(item.layout.top > visibleStart.value + props.layout.height &&
|
|
113
|
-
!item.isStatic()) // 未更新完高度的需要继续描画, 以获取其size
|
|
114
|
-
) {
|
|
115
|
-
renderList.push(item);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function addItem(key, data) {
|
|
122
|
-
const curLastItemPos =
|
|
123
|
-
itemList.length > 0
|
|
124
|
-
? itemList[itemList.length - 1].layout.top +
|
|
125
|
-
itemList[itemList.length - 1].layout.height
|
|
126
|
-
: 0;
|
|
127
|
-
const item = new ItemInfo(key, IdToken++, data, curLastItemPos);
|
|
128
|
-
itemList.push(item);
|
|
129
|
-
updateRenderList();
|
|
130
|
-
return item;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function itemUpdateDone(key) {
|
|
134
|
-
// 通过key找到对应的item,并调用其done方法
|
|
135
|
-
const item = itemList.find((item) => item.customKey === key);
|
|
136
|
-
if (item) {
|
|
137
|
-
item.done();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function totalSizeOnUpdate(width, height) {
|
|
142
|
-
// totalContentHeight.value = height;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function slideTo(position) {
|
|
146
|
-
visibleStart.value = position;
|
|
147
|
-
updateRenderList();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function goUp(distance) {
|
|
151
|
-
let newPos = Math.max(visibleStart.value - distance, 0);
|
|
152
|
-
if (visibleStart.value != newPos) {
|
|
153
|
-
enableAutoSlide = false;
|
|
154
|
-
}
|
|
155
|
-
slideTo(newPos);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function goDown(distance) {
|
|
159
|
-
let newPos;
|
|
160
|
-
if (
|
|
161
|
-
visibleStart.value + distance >=
|
|
162
|
-
totalContentHeight.value - props.layout.height
|
|
163
|
-
) {
|
|
164
|
-
enableAutoSlide = true;
|
|
165
|
-
newPos = totalContentHeight.value - props.layout.height;
|
|
166
|
-
} else {
|
|
167
|
-
enableAutoSlide = false;
|
|
168
|
-
newPos = visibleStart.value + distance;
|
|
169
|
-
}
|
|
170
|
-
slideTo(newPos);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const prePlaceHolderHeight = computed(() => {
|
|
174
|
-
if (renderList.length > 0) {
|
|
175
|
-
return renderList[0].layout.top;
|
|
176
|
-
} else {
|
|
177
|
-
//为0时, jsv-flex-div排版有问题
|
|
178
|
-
return totalContentHeight.value === 0 ? 1 : totalContentHeight.value;
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
const postPlaceHolderHeight = computed(() => {
|
|
183
|
-
if (renderList.length > 0) {
|
|
184
|
-
return (
|
|
185
|
-
totalContentHeight.value -
|
|
186
|
-
renderList[renderList.length - 1].layout.top -
|
|
187
|
-
renderList[renderList.length - 1].layout.height
|
|
188
|
-
);
|
|
189
|
-
} else {
|
|
190
|
-
return 1;
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* 获取虚拟列表的总高度
|
|
196
|
-
* @returns
|
|
197
|
-
*/
|
|
198
|
-
function getTotalHeight() {
|
|
199
|
-
return totalContentHeight.value;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* 隐藏
|
|
204
|
-
*/
|
|
205
|
-
function hide() {
|
|
206
|
-
if (isVisible) {
|
|
207
|
-
isVisible = false;
|
|
208
|
-
updateRenderList();
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* 显示
|
|
214
|
-
*/
|
|
215
|
-
function show() {
|
|
216
|
-
if (!isVisible) {
|
|
217
|
-
isVisible = true;
|
|
218
|
-
updateRenderList();
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* 设置可视范围的开始位置
|
|
224
|
-
* @param pos
|
|
225
|
-
*/
|
|
226
|
-
function setVisibleRectStart(pos) {
|
|
227
|
-
const endPos = totalContentHeight.value - props.layout.height;
|
|
228
|
-
let newPos = Math.min(endPos, Math.max(pos, 0));
|
|
229
|
-
if (newPos == visibleStart.value) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
if (newPos == endPos) {
|
|
233
|
-
enableAutoSlide = true;
|
|
234
|
-
} else {
|
|
235
|
-
enableAutoSlide = false;
|
|
236
|
-
}
|
|
237
|
-
slideTo(newPos);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
defineExpose({
|
|
241
|
-
addItem,
|
|
242
|
-
goUp,
|
|
243
|
-
goDown,
|
|
244
|
-
itemUpdateDone,
|
|
245
|
-
getTotalHeight,
|
|
246
|
-
hide,
|
|
247
|
-
show,
|
|
248
|
-
setVisibleRectStart,
|
|
249
|
-
});
|
|
250
|
-
</script>
|
|
251
|
-
|
|
252
|
-
<template>
|
|
253
|
-
<div
|
|
254
|
-
:style="{
|
|
255
|
-
width: props.layout.width,
|
|
256
|
-
height: totalContentHeight,
|
|
257
|
-
}"
|
|
258
|
-
>
|
|
259
|
-
<jsv-flex-div
|
|
260
|
-
key="root"
|
|
261
|
-
:style="{
|
|
262
|
-
flexDirection: 'column',
|
|
263
|
-
width: props.layout.width,
|
|
264
|
-
}"
|
|
265
|
-
:onSized="totalSizeOnUpdate"
|
|
266
|
-
>
|
|
267
|
-
<div
|
|
268
|
-
id="pre-placeholder"
|
|
269
|
-
:style="{
|
|
270
|
-
width: props.layout.width,
|
|
271
|
-
height: prePlaceHolderHeight,
|
|
272
|
-
}"
|
|
273
|
-
></div>
|
|
274
|
-
<template v-for="item in renderList" :key="item.id">
|
|
275
|
-
<div
|
|
276
|
-
v-if="item.isStatic()"
|
|
277
|
-
:key="item.id"
|
|
278
|
-
:style="{
|
|
279
|
-
width: props.layout.width,
|
|
280
|
-
height: item.layout.height,
|
|
281
|
-
}"
|
|
282
|
-
>
|
|
283
|
-
<slot :data="item.data"></slot>
|
|
284
|
-
</div>
|
|
285
|
-
<jsv-flex-div v-else :onSized="item.onSize" :key="item.id">
|
|
286
|
-
<slot :data="item.data"></slot>
|
|
287
|
-
</jsv-flex-div>
|
|
288
|
-
</template>
|
|
289
|
-
<div
|
|
290
|
-
id="post-placeholder"
|
|
291
|
-
:style="{
|
|
292
|
-
width: props.layout.width,
|
|
293
|
-
height: postPlaceHolderHeight,
|
|
294
|
-
}"
|
|
295
|
-
></div>
|
|
296
|
-
</jsv-flex-div>
|
|
297
|
-
</div>
|
|
298
|
-
</template>
|