@shijiu/jsview-vue-samples 1.9.747
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/AnimPicture/App.vue +207 -0
- package/AnimPicture/assets/animated_webp.webp +0 -0
- package/AnimPicture/assets/ball_3.webp +0 -0
- package/AnimPicture/assets/girl_run.gif +0 -0
- package/AnimPicture/assets/quan.webp +0 -0
- package/Basic/App.vue +134 -0
- package/Basic/assets/border.png +0 -0
- package/Basic/assets/border2.png +0 -0
- package/Basic/assets/icon.png +0 -0
- package/Basic/assets/test.jpg +0 -0
- package/Basic/components/ContentBlock.vue +38 -0
- package/Basic/components/FontStyle.css +16 -0
- package/Basic/components/anim/AnimGroup.vue +66 -0
- package/Basic/components/anim/AnimKeyframeBasic.vue +119 -0
- package/Basic/components/anim/AnimKeyframeComposite.vue +52 -0
- package/Basic/components/anim/AnimTransition.vue +157 -0
- package/Basic/components/div/DivBackground.vue +44 -0
- package/Basic/components/div/DivClip.vue +159 -0
- package/Basic/components/div/DivCssScoped.vue +20 -0
- package/Basic/components/div/DivCssVar.vue +53 -0
- package/Basic/components/div/DivGroup1.vue +47 -0
- package/Basic/components/div/DivGroup2.vue +65 -0
- package/Basic/components/div/DivLayout.vue +70 -0
- package/Basic/components/div/DivRadius.vue +65 -0
- package/Basic/components/div/DivTransform.vue +32 -0
- package/Basic/components/img/ImageGroup.vue +31 -0
- package/Basic/components/img/ImgLayout.vue +41 -0
- package/Basic/components/panel/Panel1.vue +55 -0
- package/Basic/components/panel/Panel2.vue +31 -0
- package/Basic/components/panel/TitleBar.vue +29 -0
- package/Basic/components/text/TextAlign.vue +66 -0
- package/Basic/components/text/TextEmoji.vue +26 -0
- package/Basic/components/text/TextFontStyle.vue +89 -0
- package/Basic/components/text/TextGroup1.vue +49 -0
- package/Basic/components/text/TextGroup2.vue +28 -0
- package/Basic/components/text/TextOverflow.vue +110 -0
- package/BasicFocusControl/App.vue +104 -0
- package/BasicFocusControl/components/BaseBlock.vue +50 -0
- package/BasicFocusControl/components/MainArea.vue +83 -0
- package/BasicFocusControl/components/MainAreaLeftBlock.vue +17 -0
- package/BasicFocusControl/components/MainAreaRightBlock.vue +27 -0
- package/BasicFocusControl/components/SideBar.vue +58 -0
- package/BasicFocusControl/components/SideBarBlock.vue +27 -0
- package/Collision/App.vue +452 -0
- package/ColorSpace/App.vue +126 -0
- package/ColorSpace/bmpDemo.bmp +0 -0
- package/ColorSpace/jpegDemo.jpeg +0 -0
- package/ColorSpace/pngDemo.png +0 -0
- package/ColorSpace/pngNoAlphaDemo.png +0 -0
- package/DemoHomepage/App.vue +27 -0
- package/DemoHomepage/components/BodyFrame.vue +95 -0
- package/DemoHomepage/components/Dialog.vue +94 -0
- package/DemoHomepage/components/Item.vue +77 -0
- package/DemoHomepage/components/TabFrame.vue +85 -0
- package/DemoHomepage/router.js +196 -0
- package/DemoHomepage/views/Homepage.vue +195 -0
- package/FilterDemo/AnimatePic.vue +58 -0
- package/FilterDemo/App.vue +159 -0
- package/FilterDemo/VideoLayer.vue +62 -0
- package/FilterDemo/jpegDemo.jpeg +0 -0
- package/FilterDemo/webpDemo.webp +0 -0
- package/FlipCard/App.vue +71 -0
- package/FlipCard/FlipCard.vue +118 -0
- package/FlipCard/assets/blue_egg.png +0 -0
- package/FlipCard/assets/red_egg.png +0 -0
- package/FlipCard/data.js +13 -0
- package/GridDemo/App.vue +215 -0
- package/GridDemo/ButtonBlock.vue +112 -0
- package/GridDemo/FocusItem.vue +37 -0
- package/GridDemo/Item.vue +93 -0
- package/HashHistory/App.vue +115 -0
- package/HashHistory/components/HorizontalButtonList.vue +91 -0
- package/HashHistory/components/Item.vue +60 -0
- package/HashHistory/router.js +41 -0
- package/HashHistory/views/MainPage.vue +57 -0
- package/HashHistory/views/SubPage.vue +66 -0
- package/ImpactStop/App.vue +435 -0
- package/Input/App.vue +164 -0
- package/Input/FullKeyboard.vue +87 -0
- package/Input/InputPanel.vue +131 -0
- package/Input/KeyboardItem.vue +58 -0
- package/LongImage/App.vue +80 -0
- package/LongImage/Button.vue +58 -0
- package/LongImage/ButtonItem.vue +44 -0
- package/LongImage/LongImageScroll.vue +92 -0
- package/LongImage/Scroll.vue +14 -0
- package/LongImage/assets/1280x7200.jpg +0 -0
- package/LongText/App.vue +96 -0
- package/LongText/Button.vue +51 -0
- package/LongText/ButtonItem.vue +44 -0
- package/LongText/LongTextScroll.vue +192 -0
- package/LongText/Scroll.vue +14 -0
- package/Marquee/App.vue +247 -0
- package/Marquee/longText.js +14 -0
- package/MaskClip/App.vue +122 -0
- package/MaskClip/images/mask-025/config.json +29 -0
- package/MaskClip/images/mask-025/res/1.png +0 -0
- package/MaskClip/images/mask-025/res/2.png +0 -0
- package/MaskClip/images/mask-025/res/3.png +0 -0
- package/MaskClip/images/mask-025/res/4.png +0 -0
- package/MaskClip/images/mask-025/res/icon.png +0 -0
- package/MaskClip/images/mask-025/res/stroke.png +0 -0
- package/MaskClip/images/php.jpg +0 -0
- package/MetroWidgetDemos/Advanced/App.vue +46 -0
- package/MetroWidgetDemos/Advanced/ButtonItem.vue +90 -0
- package/MetroWidgetDemos/Advanced/Buttons.vue +70 -0
- package/MetroWidgetDemos/Advanced/Mixed.vue +77 -0
- package/MetroWidgetDemos/Advanced/widgets/Item.vue +83 -0
- package/MetroWidgetDemos/Advanced/widgets/WidgetItem.vue +89 -0
- package/MetroWidgetDemos/Advanced/widgets/Widgets.vue +116 -0
- package/MetroWidgetDemos/Advanced/widgets/focus1.png +0 -0
- package/MetroWidgetDemos/Item.vue +85 -0
- package/MetroWidgetDemos/PerformanceTest/App.vue +210 -0
- package/MetroWidgetDemos/PerformanceTest/Item.vue +90 -0
- package/MetroWidgetDemos/PerformanceTest/assets/bg.jpg +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/coupon_content.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/coupon_left.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/coupon_mid.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/coupon_right.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/focus_border.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/holder_logo.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/jrbm.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/line_left.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/line_mid.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/line_right.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/loading.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/logo.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/mcjx.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/tao.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/tmall.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/border.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/components/ContentItem.vue +386 -0
- package/MetroWidgetDemos/PerformanceTest/components/MyTab.vue +129 -0
- package/MetroWidgetDemos/PerformanceTest/data.js +45 -0
- package/MetroWidgetDemos/PingPong/App.vue +135 -0
- package/MetroWidgetDemos/PingPong/AppPage.vue +73 -0
- package/MetroWidgetDemos/PingPong/AppTab.vue +62 -0
- package/MetroWidgetDemos/PingPong/TabItem.vue +84 -0
- package/MetroWidgetDemos/PingPong/ViewSwiper.vue +214 -0
- package/MetroWidgetDemos/Simple/AbsoluteTemplate.vue +75 -0
- package/MetroWidgetDemos/Simple/App.vue +45 -0
- package/MetroWidgetDemos/Simple/RelativeTemplate.vue +111 -0
- package/MetroWidgetDemos/WidgetItem.vue +89 -0
- package/MetroWidgetDemos/data.js +205 -0
- package/NinePatchDemo/App.vue +145 -0
- package/NinePatchDemo/Item.vue +69 -0
- package/NinePatchDemo/assets/border.png +0 -0
- package/Preload/App.vue +135 -0
- package/Preload/Item.vue +32 -0
- package/Preload/data.js +23 -0
- package/Preload/images/awesomeface.png +0 -0
- package/Preload/images/cat.jpg +0 -0
- package/Preload/images/rank.png +0 -0
- package/Preload/images/rank_focus.png +0 -0
- package/Preload/images/rule.png +0 -0
- package/Preload/images/rule_focus.png +0 -0
- package/Preload/images/start.png +0 -0
- package/Preload/images/start_focus.png +0 -0
- package/QrcodeDemo/App.vue +68 -0
- package/ScaleDownNeon/App.vue +107 -0
- package/SoundPool/App.vue +134 -0
- package/SoundPool/bgmusic.mp3 +0 -0
- package/SoundPool/coin.mp3 +0 -0
- package/SoundPool/jump.mp3 +0 -0
- package/SoundPool/lose.mp3 +0 -0
- package/SoundPool/run.mp3 +0 -0
- package/SprayView/App.vue +272 -0
- package/SprayView/assets/snow.png +0 -0
- package/SpriteImage/App.vue +173 -0
- package/SpriteImage/images/cat_run.png +0 -0
- package/SpriteImage/images/egg_break.json +116 -0
- package/SpriteImage/images/egg_break.png +0 -0
- package/SpriteImage/images/sprite.png +0 -0
- package/TextBox/App.vue +91 -0
- package/TextBox/RenderCenter.vue +133 -0
- package/TextBox/RenderLeft.vue +138 -0
- package/TextBox/RenderOneLine.vue +101 -0
- package/TextBox/RenderRight.vue +131 -0
- package/TextShadowDemo/App.vue +91 -0
- package/TextureAnimation/App.vue +336 -0
- package/TextureAnimation/App2.vue +111 -0
- package/TextureAnimation/assets/blackWhiteGrid.png +0 -0
- package/TextureAnimation/assets/light.png +0 -0
- package/TextureAnimation/assets/light2.png +0 -0
- package/TextureAnimation/assets/mask.png +0 -0
- package/TextureAnimation/assets/php.jpg +0 -0
- package/TextureAnimation/assets/php2.png +0 -0
- package/TextureAnimation/assets/swipLight.png +0 -0
- package/TextureSize/App.vue +132 -0
- package/TextureSize/bmpDemo.bmp +0 -0
- package/TextureSize/jpegDemo.jpeg +0 -0
- package/TextureSize/jpgDemo.jpg +0 -0
- package/TextureSize/pngDemo.png +0 -0
- package/TextureSize/pngNoAlphaDemo.png +0 -0
- package/ThrowMoveDemo/AccelerateDemo.vue +116 -0
- package/ThrowMoveDemo/App.vue +114 -0
- package/ThrowMoveDemo/LRParabolicDemo.vue +115 -0
- package/ThrowMoveDemo/TargetDemo.vue +116 -0
- package/ThrowMoveDemo/UDParabolicDemo.vue +121 -0
- package/TouchSample/App.vue +136 -0
- package/TouchSample/Item.vue +103 -0
- package/TouchSample/MetroWidgetHorizontal.vue +144 -0
- package/TouchSample/MetroWidgetVertical.vue +144 -0
- package/TouchSample/TouchContainerHorizontal.vue +160 -0
- package/TouchSample/TouchContainerVertical.vue +160 -0
- package/TouchSample/data.js +81 -0
- package/TransitPage/App.vue +29 -0
- package/VideoDemo/App.vue +121 -0
- package/VideoDemo/components/Button.vue +58 -0
- package/VideoDemo/components/Controllor.vue +197 -0
- package/VideoDemo/components/VideoFrame.vue +140 -0
- package/VisibleSensorDemo/App.vue +234 -0
- package/package.json +17 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2022-07-11 13:31:36
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2022-11-02 14:51:40
|
|
6
|
+
* @Description: file content
|
|
7
|
+
-->
|
|
8
|
+
<script setup>
|
|
9
|
+
import { MetroWidget, VERTICAL, EdgeDirection, useFocusHub } from "jsview";
|
|
10
|
+
import { useRouter } from "vue-router";
|
|
11
|
+
import Buttons from "./Buttons.vue";
|
|
12
|
+
import Mixed from "./Mixed.vue";
|
|
13
|
+
import Widgets from "./widgets/Widgets.vue";
|
|
14
|
+
|
|
15
|
+
const router = useRouter();
|
|
16
|
+
const focusHub = useFocusHub();
|
|
17
|
+
|
|
18
|
+
const onFocus = () => {
|
|
19
|
+
focusHub.setFocus("mwButton");
|
|
20
|
+
};
|
|
21
|
+
const onKeyDown = (ev) => {
|
|
22
|
+
if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
|
|
23
|
+
router.go(-1);
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
};
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<jsv-focus-block
|
|
31
|
+
autoFocus
|
|
32
|
+
:onAction="{
|
|
33
|
+
onKeyDown,
|
|
34
|
+
onFocus,
|
|
35
|
+
}"
|
|
36
|
+
:style="{
|
|
37
|
+
width: 1920,
|
|
38
|
+
height: 1080,
|
|
39
|
+
backgroundColor: '#007788',
|
|
40
|
+
}"
|
|
41
|
+
>
|
|
42
|
+
<buttons></buttons>
|
|
43
|
+
<mixed></mixed>
|
|
44
|
+
<widgets></widgets>
|
|
45
|
+
</jsv-focus-block>
|
|
46
|
+
</template>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2022-07-11 13:26:24
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2022-11-02 15:37:33
|
|
6
|
+
* @Description: file content
|
|
7
|
+
-->
|
|
8
|
+
<script setup>
|
|
9
|
+
import { ref, shallowRef } from "vue";
|
|
10
|
+
import { useFocusHub } from "jsview";
|
|
11
|
+
|
|
12
|
+
const props = defineProps({
|
|
13
|
+
data: Object,
|
|
14
|
+
query: String,
|
|
15
|
+
onAction: Object,
|
|
16
|
+
onItemEdge: Function,
|
|
17
|
+
});
|
|
18
|
+
const focusHub = useFocusHub();
|
|
19
|
+
|
|
20
|
+
let focusIndex = ref(0);
|
|
21
|
+
let focused = ref(false);
|
|
22
|
+
let focusBlock = shallowRef(null);
|
|
23
|
+
|
|
24
|
+
const onFocus = () => {
|
|
25
|
+
//onFocus时, 获得焦点, 以处理自己内部的焦点逻辑
|
|
26
|
+
focusHub.setFocus(props.data.name);
|
|
27
|
+
focused.value = true;
|
|
28
|
+
};
|
|
29
|
+
const onBlur = () => {
|
|
30
|
+
focused.value = false;
|
|
31
|
+
focusIndex.value = 0;
|
|
32
|
+
//onBlur的时候, 需要将焦点返还给父
|
|
33
|
+
focusBlock.value?.returnFocusToParent();
|
|
34
|
+
};
|
|
35
|
+
const onKeyDown = (ev) => {
|
|
36
|
+
if (ev.keyCode == 37 && focusIndex.value == 1) {
|
|
37
|
+
focusIndex.value = 0;
|
|
38
|
+
return true;
|
|
39
|
+
} else if (ev.keyCode == 39 && focusIndex.value == 0) {
|
|
40
|
+
focusIndex.value = 1;
|
|
41
|
+
return true;
|
|
42
|
+
} else if (ev.keyCode == 13) {
|
|
43
|
+
console.log("button click", props.data);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
props.onAction.register("onFocus", onFocus);
|
|
50
|
+
props.onAction.register("onBlur", onBlur);
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<jsv-focus-block
|
|
55
|
+
ref="focusBlock"
|
|
56
|
+
:name="data.name"
|
|
57
|
+
:onAction="{
|
|
58
|
+
onKeyDown: onKeyDown,
|
|
59
|
+
}"
|
|
60
|
+
>
|
|
61
|
+
<div
|
|
62
|
+
:style="{
|
|
63
|
+
width: 50,
|
|
64
|
+
height: 50,
|
|
65
|
+
fontSize: 20,
|
|
66
|
+
color: '#FFFFFF',
|
|
67
|
+
backgroundColor: '#00AA00',
|
|
68
|
+
}"
|
|
69
|
+
></div>
|
|
70
|
+
|
|
71
|
+
<div
|
|
72
|
+
:style="{
|
|
73
|
+
left: 50,
|
|
74
|
+
width: 50,
|
|
75
|
+
height: 50,
|
|
76
|
+
backgroundColor: '#0000AA',
|
|
77
|
+
}"
|
|
78
|
+
></div>
|
|
79
|
+
|
|
80
|
+
<div
|
|
81
|
+
:style="{
|
|
82
|
+
visibility: this.focused ? 'visible' : 'hidden',
|
|
83
|
+
left: 50 * focusIndex,
|
|
84
|
+
width: 10,
|
|
85
|
+
height: 10,
|
|
86
|
+
backgroundColor: '#FF0000',
|
|
87
|
+
}"
|
|
88
|
+
></div>
|
|
89
|
+
</jsv-focus-block>
|
|
90
|
+
</template>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2022-07-11 13:31:36
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2022-07-18 09:49:59
|
|
6
|
+
* @Description: file content
|
|
7
|
+
-->
|
|
8
|
+
<script setup>
|
|
9
|
+
import { MetroWidget, VERTICAL, EdgeDirection } from "jsview";
|
|
10
|
+
import { useFocusHub } from "jsview";
|
|
11
|
+
import { advanceButton } from "../data";
|
|
12
|
+
import ButtonItem from "./ButtonItem.vue";
|
|
13
|
+
|
|
14
|
+
const focusHub = useFocusHub();
|
|
15
|
+
|
|
16
|
+
//item为Buttonitem的一些回调
|
|
17
|
+
const provideData = () => {
|
|
18
|
+
return advanceButton;
|
|
19
|
+
};
|
|
20
|
+
const measures = (item) => {
|
|
21
|
+
return {
|
|
22
|
+
width: item.width,
|
|
23
|
+
height: item.height,
|
|
24
|
+
marginRight: item.marginRight,
|
|
25
|
+
marginBottom: item.marginBottom,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const onEdge = (edgeInfo) => {
|
|
29
|
+
if (edgeInfo.direction == EdgeDirection.right) {
|
|
30
|
+
focusHub.setFocus("mwWidget");
|
|
31
|
+
} else if (edgeInfo.direction == EdgeDirection.bottom) {
|
|
32
|
+
focusHub.setFocus("mwMix");
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<div
|
|
39
|
+
:style="{
|
|
40
|
+
left: 50,
|
|
41
|
+
top: 20,
|
|
42
|
+
width: 300,
|
|
43
|
+
height: 400,
|
|
44
|
+
fontSize: 30,
|
|
45
|
+
color: '#FFFFFF',
|
|
46
|
+
}"
|
|
47
|
+
>
|
|
48
|
+
{{ `item可以是可获得焦点的控件` }}
|
|
49
|
+
</div>
|
|
50
|
+
<metro-widget
|
|
51
|
+
name="mwButton"
|
|
52
|
+
:top="120"
|
|
53
|
+
:left="50"
|
|
54
|
+
:provideData="provideData"
|
|
55
|
+
:width="220"
|
|
56
|
+
:height="400"
|
|
57
|
+
:direction="VERTICAL"
|
|
58
|
+
:measures="measures"
|
|
59
|
+
:onEdge="onEdge"
|
|
60
|
+
>
|
|
61
|
+
<template #renderItem="{ data, query, onAction, onItemEdge }">
|
|
62
|
+
<button-item
|
|
63
|
+
:data="data"
|
|
64
|
+
:query="query"
|
|
65
|
+
:onAction="onAction"
|
|
66
|
+
:onItemEdge="onItemEdge"
|
|
67
|
+
/>
|
|
68
|
+
</template>
|
|
69
|
+
</metro-widget>
|
|
70
|
+
</template>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2022-07-11 13:31:36
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2022-11-02 15:37:40
|
|
6
|
+
* @Description: file content
|
|
7
|
+
-->
|
|
8
|
+
<script setup>
|
|
9
|
+
import { MetroWidget, VERTICAL, EdgeDirection } from "jsview";
|
|
10
|
+
import { useFocusHub } from "jsview";
|
|
11
|
+
import { advanceMix } from "../data";
|
|
12
|
+
import ButtonItem from "./ButtonItem.vue";
|
|
13
|
+
import Item from "../Item.vue";
|
|
14
|
+
|
|
15
|
+
const focusHub = useFocusHub();
|
|
16
|
+
|
|
17
|
+
//item混排的回调
|
|
18
|
+
const provideData = () => {
|
|
19
|
+
return advanceMix;
|
|
20
|
+
};
|
|
21
|
+
const measures = (item) => {
|
|
22
|
+
return {
|
|
23
|
+
width: item.width,
|
|
24
|
+
height: item.height,
|
|
25
|
+
marginRight: item.marginRight,
|
|
26
|
+
marginBottom: item.marginBottom,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const onEdge = (edgeInfo) => {
|
|
30
|
+
if (edgeInfo.direction == EdgeDirection.right) {
|
|
31
|
+
focusHub.setFocus("mwWidget");
|
|
32
|
+
} else if (edgeInfo.direction == EdgeDirection.top) {
|
|
33
|
+
focusHub.setFocus("mwButton");
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<template>
|
|
39
|
+
<div
|
|
40
|
+
:style="{
|
|
41
|
+
left: 50,
|
|
42
|
+
top: 350,
|
|
43
|
+
width: 300,
|
|
44
|
+
height: 400,
|
|
45
|
+
fontSize: 30,
|
|
46
|
+
color: '#FFFFFF',
|
|
47
|
+
}"
|
|
48
|
+
>
|
|
49
|
+
{{ `item可以普通描画控件和可获焦控件混排` }}
|
|
50
|
+
</div>
|
|
51
|
+
<metro-widget
|
|
52
|
+
name="mwMix"
|
|
53
|
+
:top="450"
|
|
54
|
+
:left="50"
|
|
55
|
+
:provideData="provideData"
|
|
56
|
+
:width="260"
|
|
57
|
+
:height="440"
|
|
58
|
+
:padding="{
|
|
59
|
+
top: 20,
|
|
60
|
+
left: 20,
|
|
61
|
+
}"
|
|
62
|
+
:direction="VERTICAL"
|
|
63
|
+
:measures="measures"
|
|
64
|
+
:onEdge="onEdge"
|
|
65
|
+
>
|
|
66
|
+
<template #renderItem="{ data, query, onAction, onItemEdge }">
|
|
67
|
+
<button-item
|
|
68
|
+
v-if="data.type == 'button'"
|
|
69
|
+
:data="data"
|
|
70
|
+
:query="query"
|
|
71
|
+
:onAction="onAction"
|
|
72
|
+
:onItemEdge="onItemEdge"
|
|
73
|
+
/>
|
|
74
|
+
<item v-else :data="data" :query="query" :onAction="onAction" />
|
|
75
|
+
</template>
|
|
76
|
+
</metro-widget>
|
|
77
|
+
</template>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2022-11-01 15:30:14
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2022-11-02 15:39:17
|
|
6
|
+
* @Description: file content
|
|
7
|
+
-->
|
|
8
|
+
<!--
|
|
9
|
+
* @Author: ChenChanghua
|
|
10
|
+
* @Date: 2022-05-10 15:21:24
|
|
11
|
+
* @LastEditors: ChenChanghua
|
|
12
|
+
* @LastEditTime: 2022-11-01 15:24:26
|
|
13
|
+
* @Description: file content
|
|
14
|
+
-->
|
|
15
|
+
<script setup>
|
|
16
|
+
import { ref, shallowRef, inject } from "vue";
|
|
17
|
+
|
|
18
|
+
const props = defineProps({
|
|
19
|
+
data: Object,
|
|
20
|
+
query: Object,
|
|
21
|
+
onAction: Object,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const divRef = shallowRef(null);
|
|
25
|
+
const focused = ref(false);
|
|
26
|
+
|
|
27
|
+
const focusSize = inject("focusSize");
|
|
28
|
+
|
|
29
|
+
// 自身的焦点状态自己记录, 通过回调来改变
|
|
30
|
+
const onFocus = () => {
|
|
31
|
+
focused.value = true;
|
|
32
|
+
if (focusSize) {
|
|
33
|
+
divRef.value?.getBoundingClientRect().then(
|
|
34
|
+
(data) => {
|
|
35
|
+
focusSize.width = data.width;
|
|
36
|
+
focusSize.height = data.height;
|
|
37
|
+
focusSize.left = data.left;
|
|
38
|
+
focusSize.top = data.top;
|
|
39
|
+
},
|
|
40
|
+
(error) => {
|
|
41
|
+
console.log("get absolute position failed", error);
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const onBlur = () => {
|
|
47
|
+
focused.value = false;
|
|
48
|
+
};
|
|
49
|
+
const onClick = () => {
|
|
50
|
+
console.log("item onclick ", props.data);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// 一般在create的时候进行回调的注册, 使用 option api的可以在created时进行注册
|
|
54
|
+
props.onAction.register("onFocus", onFocus);
|
|
55
|
+
props.onAction.register("onBlur", onBlur);
|
|
56
|
+
props.onAction.register("onClick", onClick);
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<template>
|
|
60
|
+
<div
|
|
61
|
+
:style="{
|
|
62
|
+
width: data.width,
|
|
63
|
+
height: data.height,
|
|
64
|
+
transform: focused ? 'scale3d(1.2, 1.2, 1.2)' : '',
|
|
65
|
+
transition: 'transform 0.2s linear',
|
|
66
|
+
}"
|
|
67
|
+
>
|
|
68
|
+
<div
|
|
69
|
+
ref="divRef"
|
|
70
|
+
:style="{
|
|
71
|
+
width: data.width,
|
|
72
|
+
height: data.height,
|
|
73
|
+
fontSize: '30px',
|
|
74
|
+
color: '#FFFFFF',
|
|
75
|
+
backgroundColor: data.color,
|
|
76
|
+
borderRadius: '10px',
|
|
77
|
+
animation: animation,
|
|
78
|
+
}"
|
|
79
|
+
>
|
|
80
|
+
{{ data.content }}
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
</template>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
|
|
2
|
+
<script setup>
|
|
3
|
+
import { HORIZONTAL, MetroWidget, useFocusHub } from "jsview";
|
|
4
|
+
import { ref, shallowRef } from "vue";
|
|
5
|
+
import Item from "./Item.vue";
|
|
6
|
+
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
data: Object,
|
|
9
|
+
query: Object,
|
|
10
|
+
onItemEdge: Function,
|
|
11
|
+
onAction: Object,
|
|
12
|
+
});
|
|
13
|
+
const focusHub = useFocusHub();
|
|
14
|
+
const mwRef = shallowRef(null);
|
|
15
|
+
|
|
16
|
+
const measures = (item) => {
|
|
17
|
+
return item;
|
|
18
|
+
};
|
|
19
|
+
const randomColor = () => {
|
|
20
|
+
let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
|
|
21
|
+
return (
|
|
22
|
+
"#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
const provideData = () => {
|
|
26
|
+
const data = [];
|
|
27
|
+
for (let i = 0; i < 10; i++) {
|
|
28
|
+
data.push({
|
|
29
|
+
width: (i + props.data.index) % 2 == 0 ? 90 : 180,
|
|
30
|
+
height: 90,
|
|
31
|
+
marginRight: 10,
|
|
32
|
+
marginBottom: 10,
|
|
33
|
+
content: i,
|
|
34
|
+
color: randomColor(),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return data;
|
|
38
|
+
};
|
|
39
|
+
const onFocus = (rect) => {
|
|
40
|
+
//获得焦点时需要做就近移动的处理, 因此需要通过setEnterFocusRect设置寻找最近焦点的区域
|
|
41
|
+
mwRef.value?.setEnterFocusRect(rect);
|
|
42
|
+
focusHub.setFocus(props.data.name);
|
|
43
|
+
};
|
|
44
|
+
const onBlur = () => {
|
|
45
|
+
//onBlur时需要返还焦点给父MetroWidget
|
|
46
|
+
mwRef.value?.getFocusBlockRef().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
|
+
:top="50"
|
|
69
|
+
:name="data.name"
|
|
70
|
+
:provideData="provideData"
|
|
71
|
+
:width="data.width"
|
|
72
|
+
:height="data.height"
|
|
73
|
+
:direction="HORIZONTAL"
|
|
74
|
+
:padding="{
|
|
75
|
+
left: 30,
|
|
76
|
+
right: 30,
|
|
77
|
+
top: 10,
|
|
78
|
+
bottom: 10,
|
|
79
|
+
}"
|
|
80
|
+
:measures="measures"
|
|
81
|
+
:slideSetting="seamlessSlide"
|
|
82
|
+
:onEdge="onItemEdge"
|
|
83
|
+
:sendFocusRectEvent="true"
|
|
84
|
+
>
|
|
85
|
+
<template #renderItem="{ data, query, onAction }">
|
|
86
|
+
<item :data="data" :query="query" :onAction="onAction" />
|
|
87
|
+
</template>
|
|
88
|
+
</metro-widget>
|
|
89
|
+
</template>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2022-07-11 13:31:36
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2022-11-02 15:35:12
|
|
6
|
+
* @Description: file content
|
|
7
|
+
-->
|
|
8
|
+
<script setup>
|
|
9
|
+
import {
|
|
10
|
+
MetroWidget,
|
|
11
|
+
VERTICAL,
|
|
12
|
+
EdgeDirection,
|
|
13
|
+
JsvNinePatch,
|
|
14
|
+
useFocusHub,
|
|
15
|
+
} from "jsview";
|
|
16
|
+
import { advanceMetroWidget } from "../../data";
|
|
17
|
+
import WidgetItem from "../widgets/WidgetItem.vue";
|
|
18
|
+
import focusImg from "./focus1.png";
|
|
19
|
+
import { ref, shallowRef, reactive, provide } from "vue";
|
|
20
|
+
|
|
21
|
+
const focusHub = useFocusHub();
|
|
22
|
+
const showFocus = ref(false);
|
|
23
|
+
|
|
24
|
+
const provideData = () => {
|
|
25
|
+
return advanceMetroWidget;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const onFocus = () => {
|
|
29
|
+
console.log("testtest", " widget onfocus");
|
|
30
|
+
showFocus.value = true;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const onBlur = () => {
|
|
34
|
+
showFocus.value = false;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const focusSize = reactive({
|
|
38
|
+
width: 0,
|
|
39
|
+
height: 0,
|
|
40
|
+
left: 0,
|
|
41
|
+
top: 0,
|
|
42
|
+
});
|
|
43
|
+
provide("focusSize", focusSize);
|
|
44
|
+
|
|
45
|
+
// measures中会返回doSlide: false, 既MetroWidget自身不处理滚动, 滚动由子的sendFocusRectEvent控制
|
|
46
|
+
const measures = (item) => {
|
|
47
|
+
return {
|
|
48
|
+
width: item.width,
|
|
49
|
+
height: item.height,
|
|
50
|
+
marginRight: item.marginRight,
|
|
51
|
+
marginBottom: item.marginBottom,
|
|
52
|
+
doSlide: false,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const onEdge = (edgeInfo) => {
|
|
56
|
+
if (edgeInfo.direction == EdgeDirection.left) {
|
|
57
|
+
focusHub.setFocus("mwButton");
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<template>
|
|
63
|
+
<div
|
|
64
|
+
:style="{
|
|
65
|
+
left: 500,
|
|
66
|
+
top: 20,
|
|
67
|
+
width: 500,
|
|
68
|
+
height: 400,
|
|
69
|
+
fontSize: 30,
|
|
70
|
+
color: '#FFFFFF',
|
|
71
|
+
}"
|
|
72
|
+
>
|
|
73
|
+
{{ `进一步, MetroWidget的item\n可以是包含MetroWidget的组件` }}
|
|
74
|
+
</div>
|
|
75
|
+
<!-- 为了保证边缘的item缩放后依旧完整显示, 需要设置padding, 注意width/height是包含padding的 -->
|
|
76
|
+
<metro-widget
|
|
77
|
+
name="mwWidget"
|
|
78
|
+
:top="100"
|
|
79
|
+
:left="400"
|
|
80
|
+
:provideData="provideData"
|
|
81
|
+
:width="660"
|
|
82
|
+
:height="600"
|
|
83
|
+
:padding="{ left: 30, right: 30 }"
|
|
84
|
+
:direction="VERTICAL"
|
|
85
|
+
:measures="measures"
|
|
86
|
+
:onEdge="onEdge"
|
|
87
|
+
:onFocus="onFocus"
|
|
88
|
+
:onBlur="onBlur"
|
|
89
|
+
>
|
|
90
|
+
<!-- data为每个item的数据, query提供获取MetroWidget内部状态的一些接口, onAction提供item注册自身回调的接口, onItemEdge则是item内部焦点处理到达边缘后, 需要通知MetroWidget时的回调 -->
|
|
91
|
+
<template #renderItem="{ data, query, onAction, onItemEdge }">
|
|
92
|
+
<widget-item
|
|
93
|
+
:data="data"
|
|
94
|
+
:query="query"
|
|
95
|
+
:onAction="onAction"
|
|
96
|
+
:onItemEdge="onItemEdge"
|
|
97
|
+
/>
|
|
98
|
+
</template>
|
|
99
|
+
</metro-widget>
|
|
100
|
+
<jsv-nine-patch
|
|
101
|
+
v-show="showFocus"
|
|
102
|
+
:style="{
|
|
103
|
+
width: focusSize.width,
|
|
104
|
+
height: focusSize.height,
|
|
105
|
+
top: focusSize.top,
|
|
106
|
+
left: focusSize.left,
|
|
107
|
+
}"
|
|
108
|
+
:imageUrl="focusImg"
|
|
109
|
+
:imageWidth="55"
|
|
110
|
+
:centerWidth="1"
|
|
111
|
+
:borderOutset="13"
|
|
112
|
+
:imageDspWidth="55"
|
|
113
|
+
:animTime="0.2"
|
|
114
|
+
:waitForInit="true"
|
|
115
|
+
></jsv-nine-patch>
|
|
116
|
+
</template>
|
|
Binary file
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2022-05-10 15:21:24
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2022-11-01 15:24:26
|
|
6
|
+
* @Description: file content
|
|
7
|
+
-->
|
|
8
|
+
<script setup>
|
|
9
|
+
import { ref, shallowRef, inject } from "vue";
|
|
10
|
+
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
data: Object,
|
|
13
|
+
query: Object,
|
|
14
|
+
onAction: Object,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const divRef = shallowRef(null);
|
|
18
|
+
const focused = ref(false);
|
|
19
|
+
|
|
20
|
+
const focusSize = inject("focusSize");
|
|
21
|
+
|
|
22
|
+
// 自身的焦点状态自己记录, 通过回调来改变
|
|
23
|
+
const onFocus = () => {
|
|
24
|
+
focused.value = true;
|
|
25
|
+
if (focusSize) {
|
|
26
|
+
divRef.value?.getBoundingClientRect().then(
|
|
27
|
+
(data) => {
|
|
28
|
+
console.log("testtest focus size", data)
|
|
29
|
+
focusSize.width = data.width;
|
|
30
|
+
focusSize.height = data.height;
|
|
31
|
+
focusSize.left = data.left;
|
|
32
|
+
focusSize.top = data.top;
|
|
33
|
+
},
|
|
34
|
+
(error) => {
|
|
35
|
+
console.log("testtest abs failed", error);
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const onBlur = () => {
|
|
41
|
+
focused.value = false;
|
|
42
|
+
};
|
|
43
|
+
const onClick = () => {
|
|
44
|
+
console.log("item onclick ", props.data);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// 一般在create的时候进行回调的注册, 使用 option api的可以在created时进行注册
|
|
48
|
+
props.onAction.register("onFocus", onFocus);
|
|
49
|
+
props.onAction.register("onBlur", onBlur);
|
|
50
|
+
props.onAction.register("onClick", onClick);
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<div
|
|
55
|
+
:style="{
|
|
56
|
+
width: data.width,
|
|
57
|
+
height: data.height,
|
|
58
|
+
transform: focused ? 'scale3d(1.2, 1.2, 1.2)' : '',
|
|
59
|
+
transition: 'transform 0.2s linear',
|
|
60
|
+
}"
|
|
61
|
+
>
|
|
62
|
+
<div
|
|
63
|
+
v-if="focused"
|
|
64
|
+
:style="{
|
|
65
|
+
left: -2,
|
|
66
|
+
top: -2,
|
|
67
|
+
width: data.width + 4,
|
|
68
|
+
height: data.height + 4,
|
|
69
|
+
backgroundColor: '#FF0000',
|
|
70
|
+
}"
|
|
71
|
+
></div>
|
|
72
|
+
<div
|
|
73
|
+
ref="divRef"
|
|
74
|
+
:style="{
|
|
75
|
+
width: data.width,
|
|
76
|
+
height: data.height,
|
|
77
|
+
fontSize: '30px',
|
|
78
|
+
color: '#FFFFFF',
|
|
79
|
+
backgroundColor: data.color,
|
|
80
|
+
}"
|
|
81
|
+
>
|
|
82
|
+
{{ data.content }}
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</template>
|