@shijiu/jsview-vue-samples 2.2.128 → 2.2.201
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/CoupletsTest/widget/Banger/Maroon.vue +4 -6
- package/CoupletsTest/widget/Fireworks/Fireworks.vue +52 -42
- package/CustomShader/App.vue +157 -0
- package/CustomShader/gaussianBlur.glsl +27 -0
- package/CustomShader/pageFlip.glsl +40 -0
- package/CustomShader/sdf.glsl +22 -0
- package/CustomShader/test.glsl +8 -0
- package/CustomShader/vortex.glsl +38 -0
- package/DemoHomepage/App.vue +36 -27
- package/DemoHomepage/router.js +10 -0
- package/DriftScopeTest/App.vue +128 -0
- package/FreeMove/App.vue +62 -64
- package/FreeMoveLink/App.vue +2 -2
- package/ImpactStop/App.vue +45 -45
- package/LongImage/App.vue +1 -2
- package/LongText/App.vue +2 -2
- package/LongText/LongTextScroll.vue +22 -22
- package/LongText/Scroll.vue +28 -9
- package/MetroWidgetDemos/RefreshDemo/App.vue +172 -56
- package/MetroWidgetDemos/RefreshDemo/ControlItem.vue +45 -0
- package/MetroWidgetDemos/RefreshDemo/Item.vue +20 -4
- package/SceneTransition/JsvSceneTransition.vue +30 -42
- package/ScrollBoxTest/App.vue +35 -86
- package/ScrollBoxTest/ClipBar.vue +153 -0
- package/ScrollBoxTest/DrawCircle.ts +25 -0
- package/ScrollBoxTest/NinePatchBar.vue +187 -0
- package/ScrollBoxTest/NoBackgroundBar.vue +125 -0
- package/ScrollBoxTest/SizeDivBar.vue +138 -0
- package/TombSweepingDayTest/Raining/Rain.vue +8 -8
- package/package.json +1 -1
- package/MetroWidgetDemos/RefreshDemo/data.js +0 -16
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, shallowRef, onBeforeUnmount } from "vue";
|
|
3
|
+
import { useRouter } from "vue-router";
|
|
4
|
+
import { JsvDriftScope, JsvNinePatch, JsvTextureStoreApi } from "jsview";
|
|
5
|
+
|
|
6
|
+
const getRandom = (start, end) => {
|
|
7
|
+
return Math.round(Math.random() * (end - start) + start);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const router = useRouter();
|
|
11
|
+
const width = ref(300);
|
|
12
|
+
const height = ref(200);
|
|
13
|
+
const left = ref(50);
|
|
14
|
+
const top = ref(80);
|
|
15
|
+
|
|
16
|
+
// 设置设定模拟绘制.9图
|
|
17
|
+
let canvasRef;
|
|
18
|
+
let sourceId = null;
|
|
19
|
+
let sampleImageWidth = 90;
|
|
20
|
+
canvasRef = JsvTextureStoreApi.canvasTexture(
|
|
21
|
+
sampleImageWidth,
|
|
22
|
+
sampleImageWidth
|
|
23
|
+
); // 创建画布
|
|
24
|
+
|
|
25
|
+
let circleInnerDiameter = 70; // 环形内直径, 为所要包括图形的borderRadius的一倍
|
|
26
|
+
let circleLineWidth = 6; // 线宽
|
|
27
|
+
let circleRadius = Math.floor(circleInnerDiameter / 2 + circleLineWidth / 2); // 绘制线是圆圈的轨迹中线
|
|
28
|
+
let customPath = canvasRef.circlePath(
|
|
29
|
+
Math.floor(sampleImageWidth / 2),
|
|
30
|
+
Math.floor(sampleImageWidth / 2),
|
|
31
|
+
circleRadius
|
|
32
|
+
); // 创建圆环绘制路径,圆形在画布的中心点位置
|
|
33
|
+
canvasRef.drawColor("rgba(0,0,0,0)"); // 画布绘制半透明底色
|
|
34
|
+
customPath.stroke(circleLineWidth, "#FF00FF7F"); // 以给定线宽绘制圆环
|
|
35
|
+
sourceId = canvasRef.commit(); // texture和div的textureStore绑定
|
|
36
|
+
|
|
37
|
+
const onKeyDown = (ev) => {
|
|
38
|
+
// 8:Backspace, 27:Escape, 10000:盒子返回键
|
|
39
|
+
if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
|
|
40
|
+
router?.go(-1); // 有router时,是从DemoHomepage进入,回退
|
|
41
|
+
} else if (ev.keyCode == 13) {
|
|
42
|
+
left.value = getRandom(50, 400);
|
|
43
|
+
top.value = getRandom(80, 200);
|
|
44
|
+
width.value = getRandom(100, 300);
|
|
45
|
+
height.value = getRandom(100, 300);
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
onBeforeUnmount(() => {
|
|
51
|
+
JsvTextureStoreApi.deleteTexture(sourceId);
|
|
52
|
+
});
|
|
53
|
+
</script>
|
|
54
|
+
<template>
|
|
55
|
+
<jsv-focus-block
|
|
56
|
+
autoFocus
|
|
57
|
+
:onKeyDown="onKeyDown"
|
|
58
|
+
:style="{
|
|
59
|
+
width: 1280,
|
|
60
|
+
height: 720,
|
|
61
|
+
}"
|
|
62
|
+
>
|
|
63
|
+
<div
|
|
64
|
+
:style="{
|
|
65
|
+
textAlign: 'center',
|
|
66
|
+
fontSize: 30,
|
|
67
|
+
lineHeight: 50,
|
|
68
|
+
color: '#ffffff',
|
|
69
|
+
left: 140,
|
|
70
|
+
top: 20,
|
|
71
|
+
width: 1000,
|
|
72
|
+
height: 50,
|
|
73
|
+
backgroundColor: 'rgba(27,38,151,0.8)',
|
|
74
|
+
}"
|
|
75
|
+
>
|
|
76
|
+
透视镜效果,OK键进行随机位置+尺寸变换
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<jsv-drift-scope
|
|
80
|
+
:frameStyle="{
|
|
81
|
+
left: left,
|
|
82
|
+
top: top,
|
|
83
|
+
transition: 'top 0.5s, left 0.5s',
|
|
84
|
+
transfrom: 'rotate3d(0deg, 0deg, 30deg)',
|
|
85
|
+
}"
|
|
86
|
+
:scopeStyle="{
|
|
87
|
+
width: width,
|
|
88
|
+
height: height,
|
|
89
|
+
transition: 'width 0.5s, height 0.5s',
|
|
90
|
+
}"
|
|
91
|
+
>
|
|
92
|
+
<template #Frame>
|
|
93
|
+
<div
|
|
94
|
+
:style="{
|
|
95
|
+
width: width,
|
|
96
|
+
height: height,
|
|
97
|
+
backgroundColor: 'rgba(0, 128, 128, 0.7)',
|
|
98
|
+
transition: 'width 0.5s, height 0.5s',
|
|
99
|
+
}"
|
|
100
|
+
/>
|
|
101
|
+
</template>
|
|
102
|
+
|
|
103
|
+
<template #Scene>
|
|
104
|
+
<div
|
|
105
|
+
:style="{
|
|
106
|
+
width: 1280,
|
|
107
|
+
height: 720,
|
|
108
|
+
backgroundImage:
|
|
109
|
+
'https://qcast-image.oss-cn-qingdao.aliyuncs.com/JsViewVideo/ImageTestSample/SceneTransition/fly2.jpg',
|
|
110
|
+
}"
|
|
111
|
+
/>
|
|
112
|
+
</template>
|
|
113
|
+
</jsv-drift-scope>
|
|
114
|
+
<jsv-nine-patch
|
|
115
|
+
:style="{
|
|
116
|
+
left: left,
|
|
117
|
+
top: top,
|
|
118
|
+
width: width,
|
|
119
|
+
height: height,
|
|
120
|
+
}"
|
|
121
|
+
:imageUrl="`jsvtexturestore://${sourceId}`"
|
|
122
|
+
:imageWidth="sampleImageWidth"
|
|
123
|
+
:centerWidth="2"
|
|
124
|
+
:borderOutset="Math.floor((sampleImageWidth - circleInnerDiameter) / 2)"
|
|
125
|
+
:animTime="500"
|
|
126
|
+
/>
|
|
127
|
+
</jsv-focus-block>
|
|
128
|
+
</template>
|
package/FreeMove/App.vue
CHANGED
|
@@ -53,46 +53,46 @@ const procKeyDown = (ev) => {
|
|
|
53
53
|
};
|
|
54
54
|
// ******* 直接跳转位置 *******
|
|
55
55
|
window.DebugResetPos = (x, y) => {
|
|
56
|
-
actorControl.run([
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
actorControl.run((cmds) => [
|
|
57
|
+
cmds.state().clearAllConditions(),
|
|
58
|
+
cmds.action().teleportTo(x, y),
|
|
59
59
|
]);
|
|
60
60
|
|
|
61
|
-
actorControl2.run([
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
actorControl2.run((cmds) => [
|
|
62
|
+
cmds.state().clearAllConditions(),
|
|
63
|
+
cmds.action().teleportTo(x, y + 50),
|
|
64
64
|
]);
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
window.DebugResetOffsetPos = (x, y) => {
|
|
68
|
-
actorControl.run([
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
actorControl.run((cmds) => [
|
|
69
|
+
cmds.state().clearAllConditions(),
|
|
70
|
+
cmds.action().teleportOffset(x, y),
|
|
71
71
|
]);
|
|
72
72
|
|
|
73
|
-
actorControl2.run([
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
actorControl2.run((cmds) => [
|
|
74
|
+
cmds.state().clearAllConditions(),
|
|
75
|
+
cmds.action().teleportOffset(x, y),
|
|
76
76
|
]);
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
// ******* 有参照物的刹车测试,仅X轴移动 *******
|
|
80
80
|
window.DebugBrakeToPosX = () => {
|
|
81
81
|
// 参照物
|
|
82
|
-
actorControl.run([
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
actorControl.run((cmds) => [
|
|
83
|
+
cmds.state().clearAllConditions(),
|
|
84
|
+
cmds.action().teleportTo(400, 50),
|
|
85
85
|
]);
|
|
86
86
|
// 运动体
|
|
87
|
-
actorControl2.run([
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
actorControl2.run((cmds) => [
|
|
88
|
+
cmds.state().clearAllConditions(),
|
|
89
|
+
cmds.state().setStartPos(0, 200),
|
|
90
|
+
cmds.action().moveTo(300, undefined, 10, undefined),
|
|
91
|
+
cmds
|
|
92
92
|
.condition()
|
|
93
93
|
.reachPosition(200, undefined)
|
|
94
94
|
.then([
|
|
95
|
-
|
|
95
|
+
cmds.action(1).brakeToPosition(
|
|
96
96
|
400,
|
|
97
97
|
undefined,
|
|
98
98
|
(a, b, c, d) => {
|
|
@@ -111,20 +111,20 @@ window.DebugBrakeToPosX = () => {
|
|
|
111
111
|
// ******* 有参照物的刹车测试,XY都移动 *******
|
|
112
112
|
window.DebugBrakeToPosXY = () => {
|
|
113
113
|
// 参照物
|
|
114
|
-
actorControl.run([
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
actorControl.run((cmds) => [
|
|
115
|
+
cmds.state().clearAllConditions(),
|
|
116
|
+
cmds.action().teleportTo(400, 50),
|
|
117
117
|
]);
|
|
118
118
|
// 运动体
|
|
119
|
-
actorControl2.run([
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
actorControl2.run((cmds) => [
|
|
120
|
+
cmds.state().clearAllConditions(),
|
|
121
|
+
cmds.state().setStartPos(800, 400),
|
|
122
|
+
cmds.action().moveTo(100, 50, 10, undefined),
|
|
123
|
+
cmds
|
|
124
124
|
.condition()
|
|
125
125
|
.reachPosition(400, undefined)
|
|
126
126
|
.then([
|
|
127
|
-
|
|
127
|
+
cmds.action(3).brakeToPosition(
|
|
128
128
|
100,
|
|
129
129
|
50,
|
|
130
130
|
(a, b, c, d) => {
|
|
@@ -142,20 +142,20 @@ window.DebugBrakeToPosXY = () => {
|
|
|
142
142
|
|
|
143
143
|
// ******* 定向移动 *******
|
|
144
144
|
window.DebugMoveTarget = () => {
|
|
145
|
-
actorControl2.run([
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
actorControl2.run((cmds) => [
|
|
146
|
+
cmds.state().clearAllConditions(),
|
|
147
|
+
cmds.state().setStartPos(0, 400),
|
|
148
|
+
cmds.action().moveTo(300, undefined, 10, undefined),
|
|
149
149
|
]);
|
|
150
150
|
};
|
|
151
151
|
|
|
152
152
|
// ******* 定向移动 + 回调监听 和 共享结束监听(OnNexusEvent) *******
|
|
153
153
|
window.DebugTestMove = (x, y) => {
|
|
154
154
|
let actRef = {};
|
|
155
|
-
actorControl.run([
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
actorControl.run((cmds) => [
|
|
156
|
+
cmds.state().clearAllConditions(),
|
|
157
|
+
cmds.state().setStartPos(160, 150),
|
|
158
|
+
cmds.action(0, 0, actRef).moveTo(x, y, 2, 2, (a, b, c, d) => {
|
|
159
159
|
console.log(
|
|
160
160
|
"LudlDebugCB DebugTestMove enter " +
|
|
161
161
|
" a=" +
|
|
@@ -168,7 +168,7 @@ window.DebugTestMove = (x, y) => {
|
|
|
168
168
|
d
|
|
169
169
|
);
|
|
170
170
|
}),
|
|
171
|
-
|
|
171
|
+
cmds
|
|
172
172
|
.condition()
|
|
173
173
|
.onNexusEvent(actRef, actEvents.ActFinish)
|
|
174
174
|
.then([
|
|
@@ -180,39 +180,37 @@ window.DebugTestMove = (x, y) => {
|
|
|
180
180
|
};
|
|
181
181
|
|
|
182
182
|
window.DebugTestOffset = (control, startPos) => {
|
|
183
|
-
control.run([
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
183
|
+
control.run((cmds) => [
|
|
184
|
+
cmds.state().clearAllConditions(),
|
|
185
|
+
cmds.state().setStartPos(startPos, 150),
|
|
186
|
+
cmds.action().altSpeed(3, undefined, 0),
|
|
187
|
+
cmds
|
|
188
188
|
.condition(undefined, true)
|
|
189
189
|
.reachPosition(460, undefined)
|
|
190
|
-
.then([
|
|
190
|
+
.then([cmds.action(1, 0).teleportOffset(-300, undefined)]),
|
|
191
191
|
]);
|
|
192
192
|
};
|
|
193
193
|
window.DebugTestThrowStart = () => {
|
|
194
194
|
// 参照物
|
|
195
|
-
actorControl2.run([
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
actorControl2.run((cmds) => [
|
|
196
|
+
cmds.state().clearAllConditions(),
|
|
197
|
+
cmds.action().teleportTo(400, 300),
|
|
198
198
|
]);
|
|
199
199
|
|
|
200
|
-
actorControl.run([
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
]);
|
|
215
|
-
}),
|
|
200
|
+
actorControl.run((cmds) => [
|
|
201
|
+
cmds.state().clearAllConditions(),
|
|
202
|
+
cmds.state().setStartPos(100, 300),
|
|
203
|
+
cmds.action().setSpeed(2, undefined),
|
|
204
|
+
cmds.action(1).setSpdAndAccel(undefined, -20, undefined, 0.3, null, () => {
|
|
205
|
+
console.log("on pole");
|
|
206
|
+
// 在接触地板时停止
|
|
207
|
+
actorControl.run((cmds) => [
|
|
208
|
+
cmds
|
|
209
|
+
.condition(undefined, true)
|
|
210
|
+
.reachPosition(undefined, 300)
|
|
211
|
+
.then([cmds.action(3, 3).stopMoving()]),
|
|
212
|
+
]);
|
|
213
|
+
}),
|
|
216
214
|
]);
|
|
217
215
|
};
|
|
218
216
|
|
package/FreeMoveLink/App.vue
CHANGED
|
@@ -16,7 +16,7 @@ onMounted(() => {
|
|
|
16
16
|
div1View.DragEnables?.(ForgeConst.DragFlags.TOUCH_RECV_MOVE_BIT); // 只激活drag
|
|
17
17
|
|
|
18
18
|
control1.run([
|
|
19
|
-
control1.state().startMovementSync(linkNexusId, -200,
|
|
19
|
+
control1.state().startMovementSync(linkNexusId, -200, 200, -200, 200, 0b11),
|
|
20
20
|
]);
|
|
21
21
|
|
|
22
22
|
let div2View = div2.value.jsvGetProxyView();
|
|
@@ -26,7 +26,7 @@ onMounted(() => {
|
|
|
26
26
|
control2
|
|
27
27
|
.condition()
|
|
28
28
|
.movementSync(linkNexusId)
|
|
29
|
-
.then([control2.action().ackMovementSync(-100,
|
|
29
|
+
.then([control2.action().ackMovementSync(-100, 100, -100, 100, 0b11, 1)]),
|
|
30
30
|
]);
|
|
31
31
|
});
|
|
32
32
|
</script>
|
package/ImpactStop/App.vue
CHANGED
|
@@ -196,16 +196,16 @@ const procKeyDown = (ev) => {
|
|
|
196
196
|
|
|
197
197
|
let interactNexus = FreeMoveFunc.newNexus();
|
|
198
198
|
|
|
199
|
-
actorControl.run([
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
actorControl.run((cmds) => [
|
|
200
|
+
cmds.state().clearAllConditions(),
|
|
201
|
+
cmds
|
|
202
202
|
.condition()
|
|
203
203
|
.onNextTick(1)
|
|
204
204
|
.then([
|
|
205
205
|
() => {
|
|
206
206
|
bodyState.value = 1;
|
|
207
207
|
},
|
|
208
|
-
|
|
208
|
+
cmds
|
|
209
209
|
.condition()
|
|
210
210
|
.onHitBlock(1)
|
|
211
211
|
.then([
|
|
@@ -213,8 +213,8 @@ const procKeyDown = (ev) => {
|
|
|
213
213
|
console.log("LudlDebug on hit 1");
|
|
214
214
|
bodyState.value = 0;
|
|
215
215
|
},
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
cmds.state().revertWithHitBlock(),
|
|
217
|
+
cmds.action().stopMoving(),
|
|
218
218
|
(a) => {
|
|
219
219
|
jumping = false;
|
|
220
220
|
|
|
@@ -239,11 +239,11 @@ const procKeyDown = (ev) => {
|
|
|
239
239
|
]);
|
|
240
240
|
|
|
241
241
|
if (direction.value) {
|
|
242
|
-
actorControl.run([
|
|
243
|
-
|
|
242
|
+
actorControl.run((cmds) => [
|
|
243
|
+
cmds
|
|
244
244
|
.action(0, 0, interactNexus)
|
|
245
245
|
.setSpdAndAccel(7.9, -24, undefined, 1, null, () => {}),
|
|
246
|
-
|
|
246
|
+
cmds
|
|
247
247
|
.condition()
|
|
248
248
|
.onNexusEvent(interactNexus, actEvents.SpeedRevertY)
|
|
249
249
|
.then([
|
|
@@ -253,11 +253,11 @@ const procKeyDown = (ev) => {
|
|
|
253
253
|
]),
|
|
254
254
|
]);
|
|
255
255
|
} else {
|
|
256
|
-
actorControl.run([
|
|
257
|
-
|
|
256
|
+
actorControl.run((cmds) => [
|
|
257
|
+
cmds
|
|
258
258
|
.action(0, 0, interactNexus)
|
|
259
259
|
.setSpdAndAccel(-7.9, -24, undefined, 1, null, () => {}),
|
|
260
|
-
|
|
260
|
+
cmds
|
|
261
261
|
.condition()
|
|
262
262
|
.onNexusEvent(interactNexus, actEvents.SpeedRevertY)
|
|
263
263
|
.then([
|
|
@@ -271,61 +271,61 @@ const procKeyDown = (ev) => {
|
|
|
271
271
|
break;
|
|
272
272
|
case 37:
|
|
273
273
|
if (board == "left") {
|
|
274
|
-
actorControl.run([
|
|
275
|
-
actorControl.run([
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
actorControl.run((cmds) => [cmds.action().setSpeed(-5, 0)]);
|
|
275
|
+
actorControl.run((cmds) => [
|
|
276
|
+
cmds.state().clearAllConditions(),
|
|
277
|
+
cmds
|
|
278
278
|
.condition()
|
|
279
279
|
.reachPosition(0, undefined)
|
|
280
|
-
.then([
|
|
280
|
+
.then([cmds.action().stopMoving()]),
|
|
281
281
|
]);
|
|
282
282
|
} else if (board == "right") {
|
|
283
|
-
actorControl.run([
|
|
284
|
-
actorControl.run([
|
|
285
|
-
|
|
286
|
-
|
|
283
|
+
actorControl.run((cmds) => [cmds.action().setSpeed(-5, 0)]);
|
|
284
|
+
actorControl.run((cmds) => [
|
|
285
|
+
cmds.state().clearAllConditions(),
|
|
286
|
+
cmds
|
|
287
287
|
.condition()
|
|
288
288
|
.reachPosition(840 - 40, undefined)
|
|
289
|
-
.then([
|
|
289
|
+
.then([cmds.action().stopMoving()]),
|
|
290
290
|
]);
|
|
291
291
|
} else if (board == "middle") {
|
|
292
|
-
actorControl.run([
|
|
293
|
-
actorControl.run([
|
|
294
|
-
|
|
295
|
-
|
|
292
|
+
actorControl.run((cmds) => [cmds.action().setSpeed(-5, 0)]);
|
|
293
|
+
actorControl.run((cmds) => [
|
|
294
|
+
cmds.state().clearAllConditions(),
|
|
295
|
+
cmds
|
|
296
296
|
.condition()
|
|
297
297
|
.reachPosition(540 - 40, undefined)
|
|
298
|
-
.then([
|
|
298
|
+
.then([cmds.action().stopMoving()]),
|
|
299
299
|
]);
|
|
300
300
|
}
|
|
301
301
|
break;
|
|
302
302
|
case 39:
|
|
303
303
|
if (board == "left") {
|
|
304
|
-
actorControl.run([
|
|
305
|
-
actorControl.run([
|
|
306
|
-
|
|
307
|
-
|
|
304
|
+
actorControl.run((cmds) => [cmds.action().setSpeed(5, 0)]);
|
|
305
|
+
actorControl.run((cmds) => [
|
|
306
|
+
cmds.state().clearAllConditions(),
|
|
307
|
+
cmds
|
|
308
308
|
.condition()
|
|
309
309
|
.reachPosition(410 - 40, undefined)
|
|
310
|
-
.then([
|
|
310
|
+
.then([cmds.action().stopMoving()]),
|
|
311
311
|
]);
|
|
312
312
|
} else if (board == "right") {
|
|
313
|
-
actorControl.run([
|
|
314
|
-
actorControl.run([
|
|
315
|
-
|
|
316
|
-
|
|
313
|
+
actorControl.run((cmds) => [cmds.action().setSpeed(5, 0)]);
|
|
314
|
+
actorControl.run((cmds) => [
|
|
315
|
+
cmds.state().clearAllConditions(),
|
|
316
|
+
cmds
|
|
317
317
|
.condition()
|
|
318
318
|
.reachPosition(1240 - 30 - 40, undefined)
|
|
319
|
-
.then([
|
|
319
|
+
.then([cmds.action().stopMoving()]),
|
|
320
320
|
]);
|
|
321
321
|
} else if (board == "middle") {
|
|
322
|
-
actorControl.run([
|
|
323
|
-
actorControl.run([
|
|
324
|
-
|
|
325
|
-
|
|
322
|
+
actorControl.run((cmds) => [cmds.action().setSpeed(5, 0)]);
|
|
323
|
+
actorControl.run((cmds) => [
|
|
324
|
+
cmds.state().clearAllConditions(),
|
|
325
|
+
cmds
|
|
326
326
|
.condition()
|
|
327
327
|
.reachPosition(740 - 40 - 30, undefined)
|
|
328
|
-
.then([
|
|
328
|
+
.then([cmds.action().stopMoving()]),
|
|
329
329
|
]);
|
|
330
330
|
}
|
|
331
331
|
break;
|
|
@@ -338,10 +338,10 @@ const procKeyUp = (ev) => {
|
|
|
338
338
|
}
|
|
339
339
|
switch (ev.keyCode) {
|
|
340
340
|
case 37:
|
|
341
|
-
actorControl.run([
|
|
341
|
+
actorControl.run((cmds) => [cmds.action().stopMoving()]);
|
|
342
342
|
break;
|
|
343
343
|
case 39:
|
|
344
|
-
actorControl.run([
|
|
344
|
+
actorControl.run((cmds) => [cmds.action().stopMoving()]);
|
|
345
345
|
break;
|
|
346
346
|
|
|
347
347
|
default:
|
|
@@ -357,7 +357,7 @@ const onActionObj = {
|
|
|
357
357
|
const reset = () => {
|
|
358
358
|
board = "left";
|
|
359
359
|
direction.value = 1;
|
|
360
|
-
actorControl.run([
|
|
360
|
+
actorControl.run((cmds) => [cmds.action().teleportTo(0, 0)]);
|
|
361
361
|
};
|
|
362
362
|
onMounted(() => {
|
|
363
363
|
actorControl = actorRef.value.control;
|
package/LongImage/App.vue
CHANGED
|
@@ -32,7 +32,6 @@ const onKeyDown = (ev) => {
|
|
|
32
32
|
};
|
|
33
33
|
</script>
|
|
34
34
|
|
|
35
|
-
|
|
36
35
|
<template>
|
|
37
36
|
<jsv-focus-block
|
|
38
37
|
autoFocus
|
|
@@ -53,7 +52,7 @@ const onKeyDown = (ev) => {
|
|
|
53
52
|
backgroundColor: 'rgba(27,38,151,0.8)',
|
|
54
53
|
}"
|
|
55
54
|
>
|
|
56
|
-
可加载长或宽超过
|
|
55
|
+
可加载长或宽超过maxBuffer(1080p:4096px)的图片
|
|
57
56
|
</div>
|
|
58
57
|
<div :style="{ left: 100, top: 100 }">
|
|
59
58
|
<LongImageScroll
|
package/LongText/App.vue
CHANGED
|
@@ -69,13 +69,13 @@ onMounted(() => {
|
|
|
69
69
|
:style="{ width: 1000, height: 500, backgroundColor: '#EEEEEE' }"
|
|
70
70
|
:textStyle="{ color: '#000000', fontSize: 20 }"
|
|
71
71
|
:scrollBlockStyle="{
|
|
72
|
-
width:
|
|
72
|
+
width: 15,
|
|
73
73
|
height: 30,
|
|
74
74
|
backgroundColor: '#555555',
|
|
75
75
|
}"
|
|
76
76
|
:scrollStyle="{
|
|
77
77
|
left: 1005,
|
|
78
|
-
width:
|
|
78
|
+
width: 15,
|
|
79
79
|
height: 500,
|
|
80
80
|
backgroundColor: '#DDDDDD',
|
|
81
81
|
}"
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
JsvFlexDiv,
|
|
7
7
|
VERTICAL,
|
|
8
8
|
JsvScrollBox,
|
|
9
|
-
|
|
9
|
+
ScrollBoxStyle,
|
|
10
10
|
} from "jsview";
|
|
11
11
|
|
|
12
12
|
const props = defineProps({
|
|
@@ -48,7 +48,7 @@ const onAction = {
|
|
|
48
48
|
case 38:
|
|
49
49
|
if (textY !== 0) {
|
|
50
50
|
text_y = textY + props.step >= 0 ? 0 : textY + props.step;
|
|
51
|
-
|
|
51
|
+
slideToYByKey(text_y);
|
|
52
52
|
}
|
|
53
53
|
break;
|
|
54
54
|
case 40:
|
|
@@ -57,7 +57,7 @@ const onAction = {
|
|
|
57
57
|
textY - props.step <= props.style.height - textTotalHeight
|
|
58
58
|
? props.style.height - textTotalHeight
|
|
59
59
|
: textY - props.step;
|
|
60
|
-
|
|
60
|
+
slideToYByKey(text_y);
|
|
61
61
|
} else {
|
|
62
62
|
focusHub.setFocus("button");
|
|
63
63
|
}
|
|
@@ -73,35 +73,37 @@ const onAction = {
|
|
|
73
73
|
},
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
function
|
|
76
|
+
function slideToYByKey(newY) {
|
|
77
77
|
// 使用新的Y来调整ScrollBox的显示位置
|
|
78
78
|
rJsvScrollBox.value.updatePercent(
|
|
79
79
|
-newY / (textTotalHeight - props.style.height)
|
|
80
80
|
);
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
recordTextY(newY);
|
|
83
|
+
|
|
84
|
+
// 不再直接更新右边进度条的进度
|
|
85
|
+
// 将由 JsvScrollBox 的syncWith机制来同步
|
|
86
|
+
// 注意: 目前这个机制在PC上没有模拟,
|
|
87
|
+
// 如果PC上也需要看到同步效果,则可通过 window.JsView 是否存在来识别非盒子情况,此时主动改变bar的top
|
|
84
88
|
}
|
|
85
89
|
|
|
86
|
-
function
|
|
90
|
+
function recordTextY(newY) {
|
|
91
|
+
// 记录text Y,为为下次按键的基准坐标
|
|
87
92
|
textY = newY;
|
|
88
|
-
|
|
89
|
-
scrollY.value =
|
|
90
|
-
(-newY / (textTotalHeight - props.style.height)) *
|
|
91
|
-
(props.scrollStyle.height - props.scrollBlockStyle.height);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
onMounted(() => {
|
|
95
96
|
rootRef.value.requestFocus();
|
|
97
|
+
|
|
98
|
+
// 检测滚动触控触发的移动,
|
|
99
|
+
// 当 updatePercent 调用后如果移动距离大于阈值也会回调
|
|
96
100
|
rJsvScrollBox.value.setSensor((percent, x, y) => {
|
|
97
101
|
let newY = Math.floor(y);
|
|
98
102
|
console.log(
|
|
99
|
-
`onProgress dragged percent=${percent}
|
|
100
|
-
x=${Math.floor(x)} \
|
|
101
|
-
y=${newY}`
|
|
103
|
+
`onProgress dragged percent=${percent} x=${Math.floor(x)} y=${newY}`
|
|
102
104
|
);
|
|
103
|
-
|
|
104
|
-
}, 15);
|
|
105
|
+
recordTextY(newY);
|
|
106
|
+
}, 15 /* 每动15px才接收一次通知,减少js被调用的频率,从而减小对性能的影响 */);
|
|
105
107
|
});
|
|
106
108
|
</script>
|
|
107
109
|
|
|
@@ -110,12 +112,14 @@ y=${newY}`
|
|
|
110
112
|
<div :style="{ overflow: 'hidden', ...style }">
|
|
111
113
|
<jsv-scroll-box
|
|
112
114
|
ref="rJsvScrollBox"
|
|
115
|
+
linkName="ScrollBoxTextArea"
|
|
116
|
+
syncWith="ScrollBarTextArea"
|
|
113
117
|
:style="{
|
|
114
118
|
width: style.width,
|
|
115
119
|
height: style.height,
|
|
116
120
|
}"
|
|
117
121
|
:direction="VERTICAL"
|
|
118
|
-
:mode="
|
|
122
|
+
:mode="ScrollBoxStyle.DrawerMode"
|
|
119
123
|
:enableFling="true"
|
|
120
124
|
:sliderSize="{
|
|
121
125
|
height: rScrollHeight == 0 ? style.height : rScrollHeight,
|
|
@@ -235,10 +239,6 @@ y=${newY}`
|
|
|
235
239
|
</template>
|
|
236
240
|
</jsv-scroll-box>
|
|
237
241
|
</div>
|
|
238
|
-
<Scroll
|
|
239
|
-
:top="scrollY"
|
|
240
|
-
:scrollStyle="scrollStyle"
|
|
241
|
-
:scrollBlockStyle="scrollBlockStyle"
|
|
242
|
-
/>
|
|
242
|
+
<Scroll :scrollStyle="scrollStyle" :scrollBlockStyle="scrollBlockStyle" />
|
|
243
243
|
</jsv-focus-block>
|
|
244
244
|
</template>
|