@shijiu/jsview-vue-samples 2.2.35 → 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/BakeViewDemo/AnimatePic.vue +93 -0
- package/BakeViewDemo/App.vue +109 -0
- package/ClickDivDemo/App.vue +150 -0
- 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/components/Dialog.vue +37 -11
- package/DemoHomepage/components/TabFrame.vue +8 -1
- package/DemoHomepage/router.js +71 -26
- package/DemoHomepage/views/Homepage.vue +30 -13
- package/DriftScopeTest/App.vue +128 -0
- package/FocusMoveStyle/App.vue +21 -4
- package/FocusMoveStyle/FoldableItem.vue +39 -12
- package/FreeMove/App.vue +62 -64
- package/FreeMoveChildAttract/App.vue +105 -0
- package/FreeMoveLink/App.vue +55 -0
- package/FreeMoveResize/App.vue +102 -0
- package/ImpactStop/App.vue +45 -45
- package/LongImage/App.vue +1 -2
- package/LongText/App.vue +3 -5
- package/LongText/LongTextScroll.vue +83 -38
- package/LongText/Scroll.vue +28 -9
- package/LongTextLatex/App.vue +93 -0
- package/LongTextLatex/Button.vue +50 -0
- package/LongTextLatex/ButtonItem.vue +44 -0
- package/LongTextLatex/LongTextScroll.vue +189 -0
- package/LongTextLatex/Scroll.vue +14 -0
- package/MetroWidgetDemos/MassiveItems/App.vue +87 -0
- package/MetroWidgetDemos/MassiveItems/ContentItem.vue +388 -0
- package/MetroWidgetDemos/MassiveItems/Item.vue +203 -0
- package/MetroWidgetDemos/MassiveItems/WidgetItem.vue +101 -0
- package/MetroWidgetDemos/MassiveItems/data.js +17 -0
- package/MetroWidgetDemos/PingPong/AppPage.vue +19 -9
- package/MetroWidgetDemos/RefreshDemo/App.vue +172 -56
- package/MetroWidgetDemos/RefreshDemo/ControlItem.vue +45 -0
- package/MetroWidgetDemos/RefreshDemo/Item.vue +20 -4
- package/MetroWidgetDemos/routeList.js +6 -0
- package/SceneTransition/JsvSceneTransition.vue +30 -42
- package/ScrollBoxTest/App.vue +109 -0
- 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/TestNativeSharedView/App.vue +166 -73
- package/TextureAnimation/App2.vue +17 -6
- package/TombSweepingDayTest/Raining/Rain.vue +8 -8
- package/TombSweepingDayTest/Raining/RainScene.vue +36 -24
- 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/FocusMoveStyle/App.vue
CHANGED
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
getTextWidth,
|
|
6
6
|
FixPositionSlide,
|
|
7
7
|
ListWidget,
|
|
8
|
+
SeamlessSlide,
|
|
9
|
+
METRO_WIDGET_CONST
|
|
8
10
|
} from "jsview";
|
|
9
11
|
import FoldableItem from "./FoldableItem.vue";
|
|
10
12
|
import redCircle from "./assets/redCircle.png";
|
|
@@ -17,20 +19,33 @@ const randomColor = () => {
|
|
|
17
19
|
"#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
|
|
18
20
|
);
|
|
19
21
|
};
|
|
20
|
-
const slideType = new FixPositionSlide();
|
|
22
|
+
// const slideType = new FixPositionSlide();
|
|
23
|
+
const slideType = new SeamlessSlide({ startPercent: .5, endPercent: .5});
|
|
24
|
+
|
|
21
25
|
const focusHub = useFocusHub();
|
|
22
26
|
|
|
23
27
|
const creepFocus = ref(null);
|
|
24
28
|
const showFocus = ref(true);
|
|
25
29
|
let currentFocusRect = {};
|
|
30
|
+
let expandItemCount = 0;
|
|
26
31
|
const focusFrameController = {
|
|
27
|
-
focusVisible: (visible) => {
|
|
28
|
-
showFocus.value = visible ? true : false;
|
|
29
|
-
},
|
|
30
32
|
onFocusChange: (rect, focusIndex, doAnim) => {
|
|
31
33
|
creepFocus.value?.changeRect(rect, doAnim);
|
|
32
34
|
currentFocusRect = rect;
|
|
33
35
|
},
|
|
36
|
+
onItemSizeChange: (ifExpand) => {
|
|
37
|
+
if (ifExpand) {
|
|
38
|
+
expandItemCount++;
|
|
39
|
+
} else {
|
|
40
|
+
expandItemCount--;
|
|
41
|
+
}
|
|
42
|
+
if (expandItemCount <= 0) {
|
|
43
|
+
showFocus.value = true;
|
|
44
|
+
expandItemCount = 0;
|
|
45
|
+
} else {
|
|
46
|
+
showFocus.value = false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
34
49
|
};
|
|
35
50
|
provide("focusFrameController", focusFrameController);
|
|
36
51
|
|
|
@@ -85,6 +100,7 @@ for (let i = 0; i < 12; ++i) {
|
|
|
85
100
|
content: contentData[i],
|
|
86
101
|
marginRight: 10,
|
|
87
102
|
name: "item_" + i, // focus name
|
|
103
|
+
expandWhenFocus: contentData[i] == "云影院" || contentData[i] == "综艺",
|
|
88
104
|
childTab: {
|
|
89
105
|
width: totalWidth, //4个item + 3个gap
|
|
90
106
|
list: childList,
|
|
@@ -110,6 +126,7 @@ const measures = (item) => {
|
|
|
110
126
|
width: item.width,
|
|
111
127
|
height: item.height,
|
|
112
128
|
marginRight: item.marginRight,
|
|
129
|
+
itemSlide: item.expandWhenFocus ? METRO_WIDGET_CONST.ITEM_SLIDE.DISABLE : METRO_WIDGET_CONST.ITEM_SLIDE.ACT_ITEM_FOCUS
|
|
113
130
|
};
|
|
114
131
|
};
|
|
115
132
|
|
|
@@ -30,6 +30,12 @@ const width = ref(props.data.width);
|
|
|
30
30
|
const widgetRef = shallowRef(null);
|
|
31
31
|
const widgetLeft = ref(0);
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* 关键代码
|
|
35
|
+
* 焦点快速往复移动时, 复用一个子widget会导致slideToDiv焦点位置的偏移, 因此每次缩放时都创建新的widget
|
|
36
|
+
*/
|
|
37
|
+
const changeToken = ref(0);
|
|
38
|
+
|
|
33
39
|
const focusRectController = {
|
|
34
40
|
onFocusChange: (rect) => {
|
|
35
41
|
creepFocus.value?.changeRect(rect);
|
|
@@ -51,15 +57,17 @@ const measures = (data) => {
|
|
|
51
57
|
|
|
52
58
|
// 注册回调
|
|
53
59
|
const onFocus = () => {
|
|
54
|
-
focusFrameController.focusVisible(true);
|
|
55
60
|
focused.value = true;
|
|
56
61
|
folded.value = true;
|
|
62
|
+
if (props.data.expandWhenFocus) {
|
|
63
|
+
expand();
|
|
64
|
+
}
|
|
57
65
|
};
|
|
58
66
|
|
|
59
67
|
const foldSubTab = () => {
|
|
60
68
|
if (!folded.value) {
|
|
61
69
|
if (width.value == props.data.childTab.width) {
|
|
62
|
-
|
|
70
|
+
changeToken.value++;
|
|
63
71
|
width.value = props.data.width;
|
|
64
72
|
let index =
|
|
65
73
|
widgetRef.value?.getCurrentFocusIndex() ?? props.data.initFocus;
|
|
@@ -86,13 +94,16 @@ const foldSubTab = () => {
|
|
|
86
94
|
},
|
|
87
95
|
{
|
|
88
96
|
duration: DURATION,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
anchor: getAnchor(widgetRef.value.getCurrentFocusIndex()),
|
|
98
|
+
onEnd: (cancel) => {
|
|
99
|
+
if (!(focused.value && props.data.expandWhenFocus)) {
|
|
100
|
+
folded.value = true;
|
|
101
|
+
}
|
|
102
|
+
console.log("fold anim end.", cancel);
|
|
93
103
|
},
|
|
94
104
|
}
|
|
95
105
|
);
|
|
106
|
+
focusFrameController.onItemSizeChange(false);
|
|
96
107
|
}
|
|
97
108
|
focusHub.returnFocusToParent();
|
|
98
109
|
}
|
|
@@ -166,11 +177,16 @@ const getAnchor = (index) => {
|
|
|
166
177
|
return anchor;
|
|
167
178
|
};
|
|
168
179
|
|
|
169
|
-
const
|
|
180
|
+
const expand = () => {
|
|
170
181
|
if (folded.value) {
|
|
182
|
+
changeToken.value++;
|
|
183
|
+
|
|
171
184
|
itemKeepScale.value = false;
|
|
172
185
|
showFocus.value = true;
|
|
173
186
|
widgetLeft.value = 0;
|
|
187
|
+
/**
|
|
188
|
+
* 动画未结束时, widgetLeft不为0, 此时又获焦那一帧同时设置的widgetLeft值未同步到div, slideToDiv获取的就不是展开后item的正确位置
|
|
189
|
+
*/
|
|
174
190
|
folded.value = false;
|
|
175
191
|
width.value = props.data.childTab.width;
|
|
176
192
|
//为了居中而计算锚点
|
|
@@ -195,8 +211,16 @@ const onClick = () => {
|
|
|
195
211
|
}
|
|
196
212
|
);
|
|
197
213
|
|
|
198
|
-
focusHub.setFocus(props.data.name);
|
|
199
|
-
focusFrameController.
|
|
214
|
+
focusHub.setFocus(props.data.name + changeToken.value);
|
|
215
|
+
focusFrameController.onItemSizeChange(true);
|
|
216
|
+
|
|
217
|
+
// focusFrameController.focusVisible(false);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const onClick = () => {
|
|
222
|
+
if (!props.data.expandWhenFocus) {
|
|
223
|
+
expand();
|
|
200
224
|
}
|
|
201
225
|
};
|
|
202
226
|
props.onAction.register("onFocus", onFocus);
|
|
@@ -205,8 +229,10 @@ props.onAction.register("onClick", onClick);
|
|
|
205
229
|
|
|
206
230
|
const onKeyDown = (ev) => {
|
|
207
231
|
if (ev.keyCode === 10000 || ev.keyCode === 8 || ev.keyCode === 27) {
|
|
208
|
-
|
|
209
|
-
|
|
232
|
+
if (!props.data.expandWhenFocus) {
|
|
233
|
+
itemKeepScale.value = true;
|
|
234
|
+
foldSubTab();
|
|
235
|
+
}
|
|
210
236
|
return true;
|
|
211
237
|
}
|
|
212
238
|
return false;
|
|
@@ -251,8 +277,9 @@ const onKeyDown = (ev) => {
|
|
|
251
277
|
}"
|
|
252
278
|
>
|
|
253
279
|
<list-widget
|
|
280
|
+
:key="changeToken"
|
|
254
281
|
ref="widgetRef"
|
|
255
|
-
:name="data.name"
|
|
282
|
+
:name="data.name + changeToken"
|
|
256
283
|
:width="data.childTab.width"
|
|
257
284
|
:height="data.height"
|
|
258
285
|
:provideData="provideData"
|
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
|
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<jsv-focus-block autoFocus :onKeyDown="procKeyDown">
|
|
3
|
+
<div class="bgStyle">
|
|
4
|
+
<jsv-free-move-div
|
|
5
|
+
ref="mActRef1"
|
|
6
|
+
:style="{
|
|
7
|
+
top: 200,
|
|
8
|
+
left: 400,
|
|
9
|
+
width: 500,
|
|
10
|
+
height: 350,
|
|
11
|
+
backgroundColor: '#00F00F',
|
|
12
|
+
}"
|
|
13
|
+
>
|
|
14
|
+
<jsv-free-move-div
|
|
15
|
+
ref="mActRef2"
|
|
16
|
+
:style="{
|
|
17
|
+
width: 50,
|
|
18
|
+
height: 50,
|
|
19
|
+
backgroundColor: '#FF0000',
|
|
20
|
+
}"
|
|
21
|
+
/>
|
|
22
|
+
</jsv-free-move-div>
|
|
23
|
+
</div>
|
|
24
|
+
</jsv-focus-block>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script setup>
|
|
28
|
+
import { JsvFreeMoveDiv, ForgeConst } from "jsview";
|
|
29
|
+
import { shallowRef, onMounted, watch } from "vue";
|
|
30
|
+
import { useRouter } from "vue-router";
|
|
31
|
+
|
|
32
|
+
const router = useRouter();
|
|
33
|
+
const procKeyDown = (ev) => {
|
|
34
|
+
// 8:Backspace, 27:Escape, 10000:盒子返回键
|
|
35
|
+
if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
|
|
36
|
+
router.go(-1); // 有router时,是从DemoHomepage进入,回退
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return false;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const mActRef1 = shallowRef(null);
|
|
44
|
+
const mActRef2 = shallowRef(null);
|
|
45
|
+
let mActControl1 = null;
|
|
46
|
+
let mActControl2 = null;
|
|
47
|
+
|
|
48
|
+
onMounted(() => {
|
|
49
|
+
mActControl1 = mActRef1.value.control;
|
|
50
|
+
mActControl2 = mActRef2.value.control;
|
|
51
|
+
|
|
52
|
+
mActControl1
|
|
53
|
+
.getBindedView()
|
|
54
|
+
.DragEnables?.(ForgeConst.DragFlags.TOUCH_RECV_FIRST_START);
|
|
55
|
+
mActControl2
|
|
56
|
+
.getBindedView()
|
|
57
|
+
.DragEnables?.(
|
|
58
|
+
ForgeConst.DragFlags.TOUCH_RECV_MOVE_BIT |
|
|
59
|
+
ForgeConst.DragFlags.TOUCH_RECV_FIRST_START |
|
|
60
|
+
ForgeConst.DragFlags.TOUCH_RECV_LAST_END
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
mActControl1.run([mActControl1.state().setTouchAttractChild(mActControl2)]);
|
|
64
|
+
|
|
65
|
+
console.log(`OnMoved starting onMovement`);
|
|
66
|
+
mActControl2.run([
|
|
67
|
+
mActControl2
|
|
68
|
+
.condition(0, true) // 通过第二个参数设置回调为多次触发
|
|
69
|
+
.onMovement(12) // 设置x或y移动超过12时才触发回调,以此减少回调的频次,规避js的性能影响
|
|
70
|
+
.then([
|
|
71
|
+
(pointInfo) => {
|
|
72
|
+
console.log(`OnMoved x=${pointInfo.xPos} y=${pointInfo.yPos}`);
|
|
73
|
+
},
|
|
74
|
+
]),
|
|
75
|
+
]);
|
|
76
|
+
window.DebugControl = mActControl1;
|
|
77
|
+
});
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
81
|
+
<style scoped>
|
|
82
|
+
.bgStyle {
|
|
83
|
+
width: 1280;
|
|
84
|
+
height: 720;
|
|
85
|
+
background-color: #007788;
|
|
86
|
+
}
|
|
87
|
+
.box {
|
|
88
|
+
width: 150;
|
|
89
|
+
height: 150;
|
|
90
|
+
font-size: 30;
|
|
91
|
+
color: #000000;
|
|
92
|
+
background-color: #3fb524;
|
|
93
|
+
}
|
|
94
|
+
.tip {
|
|
95
|
+
width: 300;
|
|
96
|
+
height: 30;
|
|
97
|
+
line-height: 28;
|
|
98
|
+
font-size: 28;
|
|
99
|
+
left: 980;
|
|
100
|
+
top: 680;
|
|
101
|
+
text-align: center;
|
|
102
|
+
font-weight: bold;
|
|
103
|
+
color: #ffffff;
|
|
104
|
+
}
|
|
105
|
+
</style>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, onMounted } from "vue";
|
|
3
|
+
import { FreeMoveFunc, ForgeConst } from "jsview";
|
|
4
|
+
|
|
5
|
+
const div1 = ref();
|
|
6
|
+
const div2 = ref();
|
|
7
|
+
|
|
8
|
+
const control1 = new FreeMoveFunc.ActControlDebug();
|
|
9
|
+
const control2 = new FreeMoveFunc.ActControlDebug();
|
|
10
|
+
|
|
11
|
+
onMounted(() => {
|
|
12
|
+
const linkNexusId = FreeMoveFunc.newNexus();
|
|
13
|
+
|
|
14
|
+
let div1View = div1.value.jsvGetProxyView();
|
|
15
|
+
control1.bindForgeView(div1View, true);
|
|
16
|
+
div1View.DragEnables?.(ForgeConst.DragFlags.TOUCH_RECV_MOVE_BIT); // 只激活drag
|
|
17
|
+
|
|
18
|
+
control1.run([
|
|
19
|
+
control1.state().startMovementSync(linkNexusId, -200, 200, -200, 200, 0b11),
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
let div2View = div2.value.jsvGetProxyView();
|
|
23
|
+
control2.bindForgeView(div2View, true);
|
|
24
|
+
div2View.DragEnables?.(ForgeConst.DragFlags.TOUCH_RECV_MOVE_BIT); // 只激活drag
|
|
25
|
+
control2.run([
|
|
26
|
+
control2
|
|
27
|
+
.condition()
|
|
28
|
+
.movementSync(linkNexusId)
|
|
29
|
+
.then([control2.action().ackMovementSync(-100, 100, -100, 100, 0b11, 1)]),
|
|
30
|
+
]);
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
<div
|
|
36
|
+
ref="div1"
|
|
37
|
+
:style="{
|
|
38
|
+
left: 50,
|
|
39
|
+
top: 50,
|
|
40
|
+
width: 300,
|
|
41
|
+
height: 300,
|
|
42
|
+
backgroundColor: '#FF0000',
|
|
43
|
+
}"
|
|
44
|
+
></div>
|
|
45
|
+
<div
|
|
46
|
+
ref="div2"
|
|
47
|
+
:style="{
|
|
48
|
+
left: 550,
|
|
49
|
+
top: 50,
|
|
50
|
+
width: 100,
|
|
51
|
+
height: 100,
|
|
52
|
+
backgroundColor: '#00FF00',
|
|
53
|
+
}"
|
|
54
|
+
></div>
|
|
55
|
+
</template>
|