@shijiu/jsview-vue 0.9.602 → 0.9.684

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.
Files changed (86) hide show
  1. package/dom/bin/jsview-browser-debug-dom.min.js +1 -1
  2. package/dom/bin/jsview-dom.min.js +1 -1
  3. package/dom/bin/jsview-engine-js-browser.min.js +1 -0
  4. package/dom/target_core_revision.js +4 -4
  5. package/package.json +1 -1
  6. package/samples/Basic/components/text/TextOverflow.vue +10 -5
  7. package/samples/Collision/App.vue +452 -0
  8. package/samples/DemoHomepage/components/BodyFrame.vue +2 -0
  9. package/samples/DemoHomepage/router.js +25 -0
  10. package/samples/DemoHomepage/views/Homepage.vue +3 -10
  11. package/samples/ImpactStop/App.vue +435 -0
  12. package/samples/Input/App.vue +8 -17
  13. package/samples/Input/InputPanel.vue +18 -11
  14. package/samples/Marquee/App.vue +176 -40
  15. package/samples/Marquee/longText.js +14 -0
  16. package/samples/MetroWidgetDemos/Advanced/App.vue +5 -6
  17. package/samples/MetroWidgetDemos/Advanced/ButtonItem.vue +1 -1
  18. package/samples/MetroWidgetDemos/Advanced/Buttons.vue +5 -5
  19. package/samples/MetroWidgetDemos/Advanced/Mixed.vue +4 -4
  20. package/samples/MetroWidgetDemos/Advanced/widgets/Item.vue +83 -0
  21. package/samples/MetroWidgetDemos/Advanced/widgets/WidgetItem.vue +89 -0
  22. package/samples/MetroWidgetDemos/Advanced/{Widgets.vue → widgets/Widgets.vue} +56 -11
  23. package/samples/MetroWidgetDemos/Advanced/widgets/focus1.png +0 -0
  24. package/samples/MetroWidgetDemos/Item.vue +20 -2
  25. package/samples/MetroWidgetDemos/PingPong/App.vue +3 -3
  26. package/samples/MetroWidgetDemos/PingPong/AppPage.vue +17 -2
  27. package/samples/MetroWidgetDemos/PingPong/AppTab.vue +3 -10
  28. package/samples/MetroWidgetDemos/PingPong/{Item.vue → TabItem.vue} +2 -10
  29. package/samples/MetroWidgetDemos/PingPong/ViewSwiper.vue +2 -2
  30. package/samples/MetroWidgetDemos/Simple/AbsoluteTemplate.vue +2 -2
  31. package/samples/MetroWidgetDemos/Simple/App.vue +2 -2
  32. package/samples/MetroWidgetDemos/Simple/RelativeTemplate.vue +4 -4
  33. package/samples/MetroWidgetDemos/data.js +2 -1
  34. package/samples/Preload/App.vue +16 -11
  35. package/samples/ScaleDownNeon/App.vue +107 -0
  36. package/samples/TextBox/App.vue +7 -81
  37. package/samples/TextBox/RenderCenter.vue +40 -16
  38. package/samples/TextBox/RenderLeft.vue +48 -19
  39. package/samples/TextBox/RenderOneLine.vue +30 -49
  40. package/samples/TextBox/RenderRight.vue +40 -16
  41. package/samples/TextShadowDemo/App.vue +11 -17
  42. package/samples/TextureAnimation/App2.vue +111 -0
  43. package/samples/TextureAnimation/assets/blackWhiteGrid.png +0 -0
  44. package/samples/TextureAnimation/assets/light.png +0 -0
  45. package/samples/TextureAnimation/assets/light2.png +0 -0
  46. package/samples/TextureAnimation/assets/mask.png +0 -0
  47. package/samples/TextureSize/App.vue +3 -3
  48. package/samples/VisibleSensorDemo/App.vue +92 -25
  49. package/utils/JsViewEngineWidget/MetroWidget/Const.js +11 -0
  50. package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +188 -80
  51. package/utils/JsViewEngineWidget/TemplateParser.js +89 -32
  52. package/utils/JsViewEngineWidget/WidgetCommon.js +3 -4
  53. package/utils/JsViewEngineWidget/index.js +3 -2
  54. package/utils/JsViewPlugin/JsvPlayer/JsvMedia.js +95 -12
  55. package/utils/JsViewPlugin/JsvPlayer/JsvPlayer.vue +25 -3
  56. package/utils/JsViewPlugin/JsvPlayer/index.js +22 -1
  57. package/utils/JsViewPlugin/JsvPlayer/version.js +4 -4
  58. package/utils/JsViewVueTools/JsvImpactTracer.js +113 -0
  59. package/utils/JsViewVueTools/index.js +2 -1
  60. package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserPreload.vue +11 -1
  61. package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserTextureAnim.vue +203 -14
  62. package/utils/JsViewVueWidget/JsvActorMove/JsvActorMove.vue +2 -2
  63. package/utils/JsViewVueWidget/JsvInput/Cursor.vue +4 -2
  64. package/utils/JsViewVueWidget/JsvInput/JsvInput.vue +13 -12
  65. package/utils/JsViewVueWidget/JsvMarquee.vue +178 -205
  66. package/utils/JsViewVueWidget/JsvNativeSharedDiv.vue +35 -27
  67. package/utils/JsViewVueWidget/JsvNinePatch.vue +1 -2
  68. package/utils/JsViewVueWidget/JsvPreload/JsvPreload.vue +37 -41
  69. package/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteAnim.vue +282 -285
  70. package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +18 -2
  71. package/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue +22 -2
  72. package/utils/JsViewVueWidget/JsvTextBox.vue +35 -72
  73. package/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue +123 -46
  74. package/utils/JsViewVueWidget/JsvTextureAnim/index.js +9 -5
  75. package/utils/JsViewVueWidget/JsvTouchContainer.vue +3 -4
  76. package/utils/JsViewVueWidget/JsvVideo.vue +9 -12
  77. package/utils/JsViewVueWidget/index.js +2 -2
  78. package/utils/JsViewVueWidget/utils/index.js +8 -0
  79. package/utils/JsViewVueWidget/utils/text.js +19 -0
  80. package/utils/JsViewEngineWidget/MetroPage.js +0 -2128
  81. package/utils/JsViewEngineWidget/SimpleWidget/ContentView.vue +0 -51
  82. package/utils/JsViewEngineWidget/SimpleWidget/Dispatcher.js +0 -19
  83. package/utils/JsViewEngineWidget/SimpleWidget/DivWrapper.vue +0 -53
  84. package/utils/JsViewEngineWidget/SimpleWidget/ItemView.vue +0 -142
  85. package/utils/JsViewEngineWidget/SimpleWidget/RootView.vue +0 -140
  86. package/utils/JsViewEngineWidget/SimpleWidget/SimpleWidget.vue +0 -1629
@@ -2,23 +2,31 @@
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2022-01-18 18:24:18
4
4
  * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-07-08 13:41:53
5
+ * @LastEditTime: 2022-11-10 15:29:12
6
6
  * @Description: file content
7
7
  -->
8
8
  <script setup>
9
9
  import { jJsvRuntimeBridge, JsvMarquee } from "jsview";
10
10
  import { useRouter } from "vue-router";
11
11
  import { onMounted } from "vue";
12
+ import { longLongText, rtlLongLongText } from "./longText";
12
13
 
13
- const width = 600;
14
- const height = 50;
15
- const fontStyle = {
16
- lineHeight: 50,
14
+ const slideSpeed = 240;
15
+ const width = 600,
16
+ height = 70;
17
+ const style = {
18
+ width,
19
+ height,
20
+ lineHeight: 70,
17
21
  fontSize: 50,
22
+ color: "#000000",
18
23
  };
19
24
  const longText =
20
25
  "石室诗士施氏,嗜狮,誓食十狮。施氏时时适市视狮。十时,适十狮适市。是时,适施氏适市。施氏视是十狮,恃矢势,使是十狮逝世。氏拾是十狮尸,适石室。石室湿,氏使侍拭石室。石室拭,施氏始试食是十狮尸。食时,始识是十狮尸,实十石狮尸。试释是事。";
21
26
  const shortText = "测试文字";
27
+
28
+ const rtlText = 'ABC انجليزي "abc" سعر الملابس 180 ';
29
+
22
30
  const router = useRouter();
23
31
 
24
32
  const _onKeyDown = (ev) => {
@@ -37,6 +45,11 @@ onMounted(() => {
37
45
  :onAction="{
38
46
  onKeyDown: _onKeyDown,
39
47
  }"
48
+ :style="{
49
+ width: 1920,
50
+ height: 1080,
51
+ backgroundColor: '#007788',
52
+ }"
40
53
  >
41
54
  <div
42
55
  :style="{
@@ -44,68 +57,191 @@ onMounted(() => {
44
57
  top: 50,
45
58
  width: width,
46
59
  height: height,
47
- backgroundColor: '#007788',
60
+ backgroundColor: '#FFFFFF',
48
61
  }"
49
62
  >
50
63
  <jsv-marquee
51
- :layoutStyles="{
52
- width: width,
53
- height: height,
54
- }"
55
- :fontStyles="fontStyle"
64
+ :style="style"
56
65
  :text="longText"
57
- :slideSpeed="120"
66
+ :slideSpeed="slideSpeed"
58
67
  :forceSlide="false"
59
68
  />
69
+ <div :style="{
70
+ left: width + 20,
71
+ height: height,
72
+ color: '#ffffff',
73
+ fontSize: 50,
74
+ lineHeight: 50,
75
+ }">
76
+ 长文字滚动
77
+ </div>
78
+ </div>
79
+ <div
80
+ :style="{
81
+ left: 50,
82
+ top: 130,
83
+ width: width,
84
+ height: height,
85
+ backgroundColor: '#FFFFFF',
86
+ }"
87
+ >
88
+ <jsv-marquee :style="style" :text="shortText" :forceSlide="false" />
89
+ <div :style="{
90
+ left: width + 20,
91
+ height: height,
92
+ color: '#ffffff',
93
+ fontSize: 50,
94
+ lineHeight: 50,
95
+ }">
96
+ 短文字不滚动
97
+ </div>
60
98
  </div>
61
99
  <div
62
100
  :style="{
63
101
  left: 50,
64
- top: 120,
102
+ top: 210,
65
103
  width: width,
66
104
  height: height,
67
- backgroundColor: '#007788',
105
+ backgroundColor: '#FFFFFF',
68
106
  }"
69
107
  >
70
108
  <jsv-marquee
71
- :layoutStyles="{
72
- width: width,
73
- height: height,
74
- }"
75
- :fontStyles="fontStyle"
109
+ :style="style"
76
110
  :text="shortText"
77
- :forceSlide="false"
111
+ :slideSpeed="slideSpeed"
112
+ :forceSlide="true"
78
113
  />
114
+ <div :style="{
115
+ left: width + 20,
116
+ height: height,
117
+ color: '#ffffff',
118
+ fontSize: 50,
119
+ lineHeight: 50,
120
+ }">
121
+ 短文字滚动
122
+ </div>
79
123
  </div>
80
124
  <div
81
125
  :style="{
82
126
  left: 50,
83
- top: 190,
127
+ top: 290,
84
128
  width: width,
85
129
  height: height,
86
- backgroundColor: '#007788',
130
+ backgroundColor: '#FFFFFF',
87
131
  }"
88
132
  >
89
133
  <jsv-marquee
90
- :layoutStyles="[
91
- {
92
- width: width,
93
- height: height,
94
- },
95
- ]"
96
- :text="shortText"
97
- :slideSpeed="60"
134
+ :style="{
135
+ width,
136
+ height,
137
+ lineHeight: 70,
138
+ fontSize: 50,
139
+ color: '#000000',
140
+ direction: 'rtl',
141
+ }"
142
+ :text="rtlText"
143
+ :slideSpeed="slideSpeed"
144
+ />
145
+ <div :style="{
146
+ left: width + 20,
147
+ height: height,
148
+ color: '#ffffff',
149
+ fontSize: 50,
150
+ lineHeight: 50,
151
+ }">
152
+ rtl文字
153
+ </div>
154
+ </div>
155
+ <div
156
+ :style="{
157
+ left: 50,
158
+ top: 370,
159
+ width: width,
160
+ height: height,
161
+ backgroundColor: '#FFFFFF',
162
+ }"
163
+ >
164
+ <jsv-marquee
165
+ :style="{
166
+ width,
167
+ height,
168
+ lineHeight: 70,
169
+ fontSize: 50,
170
+ color: '#000000',
171
+ direction: 'rtl',
172
+ }"
173
+ text="انجليزي"
174
+ :slideSpeed="slideSpeed"
98
175
  :forceSlide="true"
99
- className="test-font"
100
176
  />
177
+ <div :style="{
178
+ left: width + 20,
179
+ height: height,
180
+ color: '#ffffff',
181
+ fontSize: 50,
182
+ lineHeight: 50,
183
+ }">
184
+ rtl短文字滚动
185
+ </div>
186
+ </div>
187
+
188
+ <div
189
+ :style="{
190
+ left: 50,
191
+ top: 450,
192
+ width: width,
193
+ height: height,
194
+ backgroundColor: '#FFFFFF',
195
+ }"
196
+ >
197
+ <jsv-marquee
198
+ :style="style"
199
+ :text="longLongText"
200
+ :slideSpeed="2000"
201
+ :forceSlide="false"
202
+ />
203
+ <div :style="{
204
+ left: width + 20,
205
+ height: height,
206
+ color: '#ffffff',
207
+ fontSize: 50,
208
+ lineHeight: 50,
209
+ }">
210
+ 超长文字
211
+ </div>
101
212
  </div>
102
- </jsv-focus-block>
103
- </template>
104
213
 
105
- <style scoped>
106
- .test-font {
107
- font-size: 50;
108
- line-height: 50;
109
- color: #ff0000;
110
- }
111
- </style>
214
+ <div
215
+ :style="{
216
+ left: 50,
217
+ top: 530,
218
+ width: width,
219
+ height: height,
220
+ backgroundColor: '#FFFFFF',
221
+ }"
222
+ >
223
+ <jsv-marquee
224
+ :style="{
225
+ width,
226
+ height,
227
+ lineHeight: 70,
228
+ fontSize: 50,
229
+ color: '#000000',
230
+ direction: 'rtl',
231
+ }"
232
+ :text="rtlLongLongText"
233
+ :slideSpeed="2000"
234
+ :forceSlide="false"
235
+ />
236
+ <div :style="{
237
+ left: width + 20,
238
+ height: height,
239
+ color: '#ffffff',
240
+ fontSize: 50,
241
+ lineHeight: 50,
242
+ }">
243
+ 超长rtl文字
244
+ </div>
245
+ </div>
246
+ </jsv-focus-block>
247
+ </template>
@@ -0,0 +1,14 @@
1
+ /*
2
+ * @Author: ChenChanghua
3
+ * @Date: 2022-11-10 15:08:28
4
+ * @LastEditors: ChenChanghua
5
+ * @LastEditTime: 2022-11-10 15:21:11
6
+ * @Description: file content
7
+ */
8
+ const longLongText =
9
+ "艾因小萌班用户服务协议及隐私权保护政策特别提示:欢迎您使用“艾因小萌班”。本用户服务协议及隐私权保护政策(下称“本协议”)是您与运营方之间订立的具有法律效力的合同。请您仔细阅读并充分理解本协议各条款内容,特别是涉及免除或者限制责任的条款、权利许可和信息使用的条款、同意开通和使用特殊单项服务的条款、法律适用和争议解决条款等。其中,免除或者限制责任条款等重要内容可能以下划线/加粗进行提示您,您应重点阅读。未成年人用户请在法定监护人陪同下仔细阅读并充分理解本协议,并征得法定监护人的同意后使用“艾因小萌班”。除非您完全接受本协议的全部内容,否则您无权下载、注册、登录、使用(以下统称“使用”)“艾因小萌班”,或者通过任何方式使用“艾因小萌班”服务,或者获得“艾因小萌班”提供的任何服务(本协议中统称“使用”)。若您使用“艾因小萌班”及相关服务,则视为您已充分理解本协议并承诺作为本协议的一方当事人接受协议的约束,您不得以未仔细阅读、未充分理解等理由拒绝接受本协议的约束。本协议内容或不能保证完全符合未来业务发展需求。为此,您同意运营方保留随时修改本协议的权利。本协议条款修改后,运营方将及时公布,您同意予以密切关注。如果您继续使用艾因小萌班,即视为您完全接受修改后的协议。如果您不接受修改后的协议,请立即停止使用艾因小萌班。关于艾因小萌班的使用您使用“艾因小萌班”及相关服务,登录后,系统将为您自动匹配一个不可更改的用户ID,您应妥善保管该用户ID并对以您用户ID所进行的所有活动负法律责任。";
10
+
11
+ const rtlLongLongText =
12
+ "مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم مرحبا بالعالم ";
13
+
14
+ export { longLongText, rtlLongLongText };
@@ -2,22 +2,21 @@
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2022-07-11 13:31:36
4
4
  * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-07-18 10:00:27
5
+ * @LastEditTime: 2022-11-02 14:51:40
6
6
  * @Description: file content
7
7
  -->
8
8
  <script setup>
9
- import { MetroWidget, VERTICAL, EdgeDirection } from "jsview";
9
+ import { MetroWidget, VERTICAL, EdgeDirection, useFocusHub } from "jsview";
10
10
  import { useRouter } from "vue-router";
11
- import { useFocusHub } from "jsview";
12
11
  import Buttons from "./Buttons.vue";
13
12
  import Mixed from "./Mixed.vue";
14
- import Widgets from "./Widgets.vue";
13
+ import Widgets from "./widgets/Widgets.vue";
15
14
 
16
15
  const router = useRouter();
17
- const foucsHub = useFocusHub();
16
+ const focusHub = useFocusHub();
18
17
 
19
18
  const onFocus = () => {
20
- foucsHub.setFocus("mwButton");
19
+ focusHub.setFocus("mwButton");
21
20
  };
22
21
  const onKeyDown = (ev) => {
23
22
  if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
@@ -2,7 +2,7 @@
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2022-07-11 13:26:24
4
4
  * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-07-11 17:00:47
5
+ * @LastEditTime: 2022-11-02 15:37:33
6
6
  * @Description: file content
7
7
  -->
8
8
  <script setup>
@@ -11,7 +11,7 @@ import { useFocusHub } from "jsview";
11
11
  import { advanceButton } from "../data";
12
12
  import ButtonItem from "./ButtonItem.vue";
13
13
 
14
- const foucsHub = useFocusHub();
14
+ const focusHub = useFocusHub();
15
15
 
16
16
  //item为Buttonitem的一些回调
17
17
  const provideData = () => {
@@ -27,9 +27,9 @@ const measures = (item) => {
27
27
  };
28
28
  const onEdge = (edgeInfo) => {
29
29
  if (edgeInfo.direction == EdgeDirection.right) {
30
- foucsHub.setFocus("mwWidget");
30
+ focusHub.setFocus("mwWidget");
31
31
  } else if (edgeInfo.direction == EdgeDirection.bottom) {
32
- foucsHub.setFocus("mwMix");
32
+ focusHub.setFocus("mwMix");
33
33
  }
34
34
  };
35
35
  </script>
@@ -38,7 +38,7 @@ const onEdge = (edgeInfo) => {
38
38
  <div
39
39
  :style="{
40
40
  left: 50,
41
- top: 50,
41
+ top: 20,
42
42
  width: 300,
43
43
  height: 400,
44
44
  fontSize: 30,
@@ -49,7 +49,7 @@ const onEdge = (edgeInfo) => {
49
49
  </div>
50
50
  <metro-widget
51
51
  name="mwButton"
52
- :top="150"
52
+ :top="120"
53
53
  :left="50"
54
54
  :provideData="provideData"
55
55
  :width="220"
@@ -2,7 +2,7 @@
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2022-07-11 13:31:36
4
4
  * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-07-18 09:57:40
5
+ * @LastEditTime: 2022-11-02 15:37:40
6
6
  * @Description: file content
7
7
  -->
8
8
  <script setup>
@@ -12,7 +12,7 @@ import { advanceMix } from "../data";
12
12
  import ButtonItem from "./ButtonItem.vue";
13
13
  import Item from "../Item.vue";
14
14
 
15
- const foucsHub = useFocusHub();
15
+ const focusHub = useFocusHub();
16
16
 
17
17
  //item混排的回调
18
18
  const provideData = () => {
@@ -28,9 +28,9 @@ const measures = (item) => {
28
28
  };
29
29
  const onEdge = (edgeInfo) => {
30
30
  if (edgeInfo.direction == EdgeDirection.right) {
31
- foucsHub.setFocus("mwWidget");
31
+ focusHub.setFocus("mwWidget");
32
32
  } else if (edgeInfo.direction == EdgeDirection.top) {
33
- foucsHub.setFocus("mwButton");
33
+ focusHub.setFocus("mwButton");
34
34
  }
35
35
  };
36
36
  </script>
@@ -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, inject } from "vue";
17
+
18
+ const props = defineProps({
19
+ data: Object,
20
+ query: Object,
21
+ onAction: Object,
22
+ });
23
+
24
+ const divRef = ref(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 } 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 = ref(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>
@@ -2,21 +2,46 @@
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2022-07-11 13:31:36
4
4
  * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-07-18 09:59:32
5
+ * @LastEditTime: 2022-11-02 15:35:12
6
6
  * @Description: file content
7
7
  -->
8
8
  <script setup>
9
- import { MetroWidget, VERTICAL, EdgeDirection } from "jsview";
10
- import { useFocusHub } from "jsview";
11
- import { advanceMetroWidget } from "../data";
12
- import WidgetItem from "../WidgetItem.vue";
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, reactive, provide } from "vue";
13
20
 
14
- const foucsHub = useFocusHub();
21
+ const focusHub = useFocusHub();
22
+ const showFocus = ref(false);
15
23
 
16
- //item为Widgetitem的一些回调
17
24
  const provideData = () => {
18
25
  return advanceMetroWidget;
19
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
+
20
45
  // measures中会返回doSlide: false, 既MetroWidget自身不处理滚动, 滚动由子的sendFocusRectEvent控制
21
46
  const measures = (item) => {
22
47
  return {
@@ -29,7 +54,7 @@ const measures = (item) => {
29
54
  };
30
55
  const onEdge = (edgeInfo) => {
31
56
  if (edgeInfo.direction == EdgeDirection.left) {
32
- foucsHub.setFocus("mwButton");
57
+ focusHub.setFocus("mwButton");
33
58
  }
34
59
  };
35
60
  </script>
@@ -38,7 +63,7 @@ const onEdge = (edgeInfo) => {
38
63
  <div
39
64
  :style="{
40
65
  left: 500,
41
- top: 50,
66
+ top: 20,
42
67
  width: 500,
43
68
  height: 400,
44
69
  fontSize: 30,
@@ -47,16 +72,20 @@ const onEdge = (edgeInfo) => {
47
72
  >
48
73
  {{ `进一步, MetroWidget的item\n可以是包含MetroWidget的组件` }}
49
74
  </div>
75
+ <!-- 为了保证边缘的item缩放后依旧完整显示, 需要设置padding, 注意width/height是包含padding的 -->
50
76
  <metro-widget
51
77
  name="mwWidget"
52
- :top="150"
78
+ :top="100"
53
79
  :left="400"
54
80
  :provideData="provideData"
55
- :width="600"
81
+ :width="660"
56
82
  :height="600"
83
+ :padding="{ left: 30, right: 30 }"
57
84
  :direction="VERTICAL"
58
85
  :measures="measures"
59
86
  :onEdge="onEdge"
87
+ :onFocus="onFocus"
88
+ :onBlur="onBlur"
60
89
  >
61
90
  <!-- data为每个item的数据, query提供获取MetroWidget内部状态的一些接口, onAction提供item注册自身回调的接口, onItemEdge则是item内部焦点处理到达边缘后, 需要通知MetroWidget时的回调 -->
62
91
  <template #renderItem="{ data, query, onAction, onItemEdge }">
@@ -68,4 +97,20 @@ const onEdge = (edgeInfo) => {
68
97
  />
69
98
  </template>
70
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>
71
116
  </template>