@shijiu/jsview-vue-samples 2.1.367-test.0 → 2.1.428
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/App.vue +37 -52
- package/CoupletsTest/widget/Fireworks/Fireworks.vue +173 -45
- package/DemoHomepage/router.js +19 -3
- package/FlexCellDemo/App.vue +315 -0
- package/FlexCellDemo/images/1.png +0 -0
- package/FlexCellDemo/images/2.png +0 -0
- package/FlexCellDemo/images/3.png +0 -0
- package/FlexCellDemo/images/4.jpg +0 -0
- package/FlexCellDemo/images/5.png +0 -0
- package/GradientTexture/App.vue +135 -0
- package/ImpactStop/App.vue +1 -1
- package/LongText/LongTextScroll.vue +3 -7
- package/QrcodeDemo/App.vue +37 -9
- package/SceneTransition/App.vue +177 -0
- package/SceneTransition/JsvSceneTransition.vue +181 -0
- package/SceneTransition/images/fly1.jpg +0 -0
- package/SceneTransition/images/fly2.jpg +0 -0
- package/SceneTransition/images/mask/1.png +0 -0
- package/SceneTransition/images/mask/10.png +0 -0
- package/SceneTransition/images/mask/11.png +0 -0
- package/SceneTransition/images/mask/12.png +0 -0
- package/SceneTransition/images/mask/2.png +0 -0
- package/SceneTransition/images/mask/3.png +0 -0
- package/SceneTransition/images/mask/4.png +0 -0
- package/SceneTransition/images/mask/5.png +0 -0
- package/SceneTransition/images/mask/6.png +0 -0
- package/SceneTransition/images/mask/7.png +0 -0
- package/SceneTransition/images/mask/8.png +0 -0
- package/SceneTransition/images/mask/9.png +0 -0
- package/SceneTransition/images/mask-025/config.json +29 -0
- package/SceneTransition/images/mask-025/res/1.png +0 -0
- package/SceneTransition/images/mask-025/res/2.png +0 -0
- package/SceneTransition/images/mask-025/res/3.png +0 -0
- package/SceneTransition/images/mask-025/res/4.png +0 -0
- package/SceneTransition/images/mask-025/res/icon.png +0 -0
- package/SceneTransition/images/mask-025/res/stroke.png +0 -0
- package/SceneTransition/images/sample.png +0 -0
- package/SecTorTest/App.vue +145 -23
- package/SwiperTest/App.vue +4 -4
- package/TouchWidget/App.vue +95 -0
- package/TouchWidget/Item.vue +64 -0
- package/TouchWidget/WidgetItem.vue +96 -0
- package/package.json +1 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2022-07-11 13:31:36
|
|
4
|
+
* @Description: file content
|
|
5
|
+
-->
|
|
6
|
+
<script setup>
|
|
7
|
+
import { MetroWidget, VERTICAL, useFocusHub, METRO_WIDGET_CONST } from "jsview";
|
|
8
|
+
import WidgetItem from "./WidgetItem.vue";
|
|
9
|
+
import { onMounted } from "vue";
|
|
10
|
+
|
|
11
|
+
const focusHub = useFocusHub();
|
|
12
|
+
|
|
13
|
+
const provideData = () => {
|
|
14
|
+
const data = [];
|
|
15
|
+
for (let i = 0; i < 10; i++) {
|
|
16
|
+
data.push({
|
|
17
|
+
width: 500,
|
|
18
|
+
height: 190,
|
|
19
|
+
name: "widget_" + i,
|
|
20
|
+
marginBottom: 10,
|
|
21
|
+
index: i,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const measures = (item) => {
|
|
28
|
+
return {
|
|
29
|
+
width: item.width,
|
|
30
|
+
height: item.height,
|
|
31
|
+
marginRight: item.marginRight,
|
|
32
|
+
marginBottom: item.marginBottom,
|
|
33
|
+
/**重要代码: itemSlide设置为ACT_FOCUS_RECT_EVENT, 由子MetroWidget控制滚动 */
|
|
34
|
+
itemSlide: METRO_WIDGET_CONST.ITEM_SLIDE.ACT_FOCUS_RECT_EVENT,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
onMounted(() => {
|
|
39
|
+
focusHub.setFocus("mwWidget");
|
|
40
|
+
});
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<template>
|
|
44
|
+
<div :style="{ width: 1280, height: 720, backgroundColor: '#007788' }" />
|
|
45
|
+
<div
|
|
46
|
+
:style="{
|
|
47
|
+
left: 100,
|
|
48
|
+
top: 20,
|
|
49
|
+
width: 800,
|
|
50
|
+
height: 400,
|
|
51
|
+
fontSize: 30,
|
|
52
|
+
color: '#FFFFFF',
|
|
53
|
+
}"
|
|
54
|
+
>
|
|
55
|
+
{{ `MetroWidget的item是包含MetroWidget的组件` }}
|
|
56
|
+
</div>
|
|
57
|
+
<!-- 为了保证边缘的item缩放后依旧完整显示, 需要设置padding, 注意width/height是包含padding的 -->
|
|
58
|
+
<metro-widget
|
|
59
|
+
name="mwWidget"
|
|
60
|
+
:top="10"
|
|
61
|
+
:left="50"
|
|
62
|
+
:width="660"
|
|
63
|
+
:height="600"
|
|
64
|
+
:provideData="provideData"
|
|
65
|
+
:padding="{ left: 30, right: 30 }"
|
|
66
|
+
:direction="VERTICAL"
|
|
67
|
+
:measures="measures"
|
|
68
|
+
:touchFlag="1"
|
|
69
|
+
>
|
|
70
|
+
<!-- 重要代码: 为了实现焦点就近移动, 需要传递onItemEdge回调 -->
|
|
71
|
+
<template #renderItem="{ data, onAction, onItemEdge }">
|
|
72
|
+
<widget-item :data="data" :onAction="onAction" :onItemEdge="onItemEdge" />
|
|
73
|
+
</template>
|
|
74
|
+
</metro-widget>
|
|
75
|
+
|
|
76
|
+
<div
|
|
77
|
+
:style="{
|
|
78
|
+
width: 50,
|
|
79
|
+
height: 50,
|
|
80
|
+
backgroundColor: '#ff000055',
|
|
81
|
+
animation: 'testRotate 2s infinite',
|
|
82
|
+
}"
|
|
83
|
+
></div>
|
|
84
|
+
</template>
|
|
85
|
+
|
|
86
|
+
<style scoped>
|
|
87
|
+
@keyframes testRotate {
|
|
88
|
+
from {
|
|
89
|
+
transform: rotate3d(0, 0, 1, 0deg);
|
|
90
|
+
}
|
|
91
|
+
to {
|
|
92
|
+
transform: rotate3d(0, 0, 1, 360deg);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
</style>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2023-03-09 15:33:54
|
|
4
|
+
* @Description: file content
|
|
5
|
+
-->
|
|
6
|
+
<script setup>
|
|
7
|
+
import { ref } from "vue";
|
|
8
|
+
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
data: Object,
|
|
11
|
+
onAction: Object,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const focused = ref(false);
|
|
15
|
+
|
|
16
|
+
// 自身的焦点状态自己记录, 通过回调来改变
|
|
17
|
+
const onFocus = () => {
|
|
18
|
+
focused.value = true;
|
|
19
|
+
};
|
|
20
|
+
const onBlur = () => {
|
|
21
|
+
focused.value = false;
|
|
22
|
+
};
|
|
23
|
+
const onClick = () => {
|
|
24
|
+
console.log("testtest item onclick ", props.data);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// 一般在create的时候进行回调的注册, 使用 option api的可以在created时进行注册
|
|
28
|
+
props.onAction.register("onFocus", onFocus);
|
|
29
|
+
props.onAction.register("onBlur", onBlur);
|
|
30
|
+
props.onAction.register("onClick", onClick);
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<div
|
|
35
|
+
:style="{
|
|
36
|
+
width: data.width,
|
|
37
|
+
height: data.height,
|
|
38
|
+
transform: focused ? 'scale3d(1.2, 1.2, 1.2)' : '',
|
|
39
|
+
transition: 'transform 0.2s linear',
|
|
40
|
+
}"
|
|
41
|
+
>
|
|
42
|
+
<div
|
|
43
|
+
v-if="focused"
|
|
44
|
+
:style="{
|
|
45
|
+
left: -2,
|
|
46
|
+
top: -2,
|
|
47
|
+
width: data.width + 4,
|
|
48
|
+
height: data.height + 4,
|
|
49
|
+
backgroundColor: '#FF0000',
|
|
50
|
+
}"
|
|
51
|
+
/>
|
|
52
|
+
<div
|
|
53
|
+
:style="{
|
|
54
|
+
width: data.width,
|
|
55
|
+
height: data.height,
|
|
56
|
+
fontSize: 30,
|
|
57
|
+
color: '#FFFFFF',
|
|
58
|
+
backgroundColor: data.color,
|
|
59
|
+
}"
|
|
60
|
+
>
|
|
61
|
+
{{ data.content }}
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { HORIZONTAL, MetroWidget, useFocusHub } from "jsview";
|
|
3
|
+
import { shallowRef } from "vue";
|
|
4
|
+
import Item from "./Item.vue";
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
data: Object,
|
|
8
|
+
onItemEdge: Function,
|
|
9
|
+
onAction: Object,
|
|
10
|
+
});
|
|
11
|
+
const focusHub = useFocusHub();
|
|
12
|
+
const mwRef = shallowRef(null);
|
|
13
|
+
|
|
14
|
+
const measures = (item) => {
|
|
15
|
+
return item;
|
|
16
|
+
};
|
|
17
|
+
const randomColor = () => {
|
|
18
|
+
let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
|
|
19
|
+
return (
|
|
20
|
+
"#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
const provideData = () => {
|
|
24
|
+
const data = [];
|
|
25
|
+
for (let i = 0; i < 10; i++) {
|
|
26
|
+
data.push({
|
|
27
|
+
width: (i + props.data.index) % 2 == 0 ? 90 : 180,
|
|
28
|
+
height: 90,
|
|
29
|
+
marginRight: 10,
|
|
30
|
+
marginBottom: 10,
|
|
31
|
+
content: i,
|
|
32
|
+
color: randomColor(),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return data;
|
|
36
|
+
};
|
|
37
|
+
const onFocus = (rect) => {
|
|
38
|
+
/** 重要代码: 参数rect为父MetroWidget传递的, 焦点过来的区域
|
|
39
|
+
* 因此需要调用setEnterFocusRect来设置焦点进入区域, 以寻找最近的焦点
|
|
40
|
+
*/
|
|
41
|
+
mwRef.value?.setEnterFocusRect(rect);
|
|
42
|
+
focusHub.setFocus(props.data.name);
|
|
43
|
+
};
|
|
44
|
+
const onBlur = () => {
|
|
45
|
+
//onBlur时需要返还焦点给父MetroWidget
|
|
46
|
+
focusHub.returnFocusToParent();
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
props.onAction.register("onFocus", onFocus);
|
|
50
|
+
props.onAction.register("onBlur", onBlur);
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<div
|
|
55
|
+
:style="{
|
|
56
|
+
width: 900,
|
|
57
|
+
height: 50,
|
|
58
|
+
fontSize: 30,
|
|
59
|
+
color: '#FFFFFF',
|
|
60
|
+
}"
|
|
61
|
+
>
|
|
62
|
+
{{ data.name }}
|
|
63
|
+
</div>
|
|
64
|
+
<!-- 重要代码: sendFocusRectEvent可以让MetroWidget的item在获焦时发送事件, 通知父的MetroWidget进行滚动 -->
|
|
65
|
+
<!-- 重要代码: onItemEdge直接作为onEdge回调, 既子MetroWidget到达边缘时触发父的onItemEdge -->
|
|
66
|
+
<metro-widget
|
|
67
|
+
ref="mwRef"
|
|
68
|
+
:name="data.name"
|
|
69
|
+
:top="50"
|
|
70
|
+
:width="data.width"
|
|
71
|
+
:height="data.height"
|
|
72
|
+
:provideData="provideData"
|
|
73
|
+
:direction="HORIZONTAL"
|
|
74
|
+
:padding="{
|
|
75
|
+
left: 30,
|
|
76
|
+
right: 30,
|
|
77
|
+
top: 10,
|
|
78
|
+
bottom: 10,
|
|
79
|
+
}"
|
|
80
|
+
:measures="measures"
|
|
81
|
+
:onEdge="onItemEdge"
|
|
82
|
+
:sendFocusRectEvent="true"
|
|
83
|
+
:touchFlag="1"
|
|
84
|
+
:enableItemRenderBreak="true"
|
|
85
|
+
:placeHolderSetting="{
|
|
86
|
+
backgroundColor: 'rgba(78,105,127, 0.8)',
|
|
87
|
+
focusBackgroundColor: '#770088aa',
|
|
88
|
+
borderRadius: 10,
|
|
89
|
+
gap: 10,
|
|
90
|
+
}"
|
|
91
|
+
>
|
|
92
|
+
<template #renderItem="{ data, onAction }">
|
|
93
|
+
<item :data="data" :onAction="onAction" />
|
|
94
|
+
</template>
|
|
95
|
+
</metro-widget>
|
|
96
|
+
</template>
|