@shijiu/jsview-vue-samples 2.2.426-test.0 → 2.3.151-test.0

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 (246) hide show
  1. package/BakeViewDemo/AnimatePic.vue +1 -1
  2. package/Basic/components/text/TextDirection.vue +7 -1
  3. package/BasicFocusControl/components/BaseBlock.vue +65 -18
  4. package/BreakRender/assets/imageList.json +235 -235
  5. package/ColorSpace/App.vue +2 -2
  6. package/CoupletsTest/App.vue +1 -1
  7. package/CoupletsTest/widget/Banger/Banger.vue +3 -3
  8. package/CoupletsTest/widget/Banger/MaroonLoader.vue +5 -5
  9. package/CoupletsTest/widget/Couplets/Couplets.vue +4 -4
  10. package/CoupletsTest/widget/Fireworks/Fireworks.vue +13 -13
  11. package/CustomShader/App.vue +4 -4
  12. package/CustomShader/gaussianBlur.glsl +1 -1
  13. package/DashPath/App.vue +80 -0
  14. package/DashPath/AppForOperator.vue +33 -0
  15. package/DemoForOperator/AnimPic/AnimPic.vue +69 -0
  16. package/DemoForOperator/AnimPic/App.vue +28 -0
  17. package/DemoForOperator/Banger/App.vue +26 -0
  18. package/DemoForOperator/Banger/Banger/Banger.vue +316 -0
  19. package/DemoForOperator/Banger/Banger/Maroon.vue +123 -0
  20. package/DemoForOperator/Banger/Banger/MaroonLoader.vue +78 -0
  21. package/DemoForOperator/Banger/Banger/SpriteDeal.js +30 -0
  22. package/DemoForOperator/Blur/Blur.vue +146 -0
  23. package/DemoForOperator/Blur/BlurInOut/BlurInOut.vue +158 -0
  24. package/DemoForOperator/Blur/BlurInOut/StaticBgSlide.vue +162 -0
  25. package/DemoForOperator/Blur/BlurPopup/BlurPopup.vue +113 -0
  26. package/DemoForOperator/BookFlip/App.vue +115 -0
  27. package/DemoForOperator/BookFlip/BookFlip/FlipPage.vue +179 -0
  28. package/DemoForOperator/BookFlip/BookFlip/FlippingBook.vue +310 -0
  29. package/DemoForOperator/BookFlip/BookFlip/flip.glsl +135 -0
  30. package/DemoForOperator/BookFlip/BookPage.vue +82 -0
  31. package/DemoForOperator/Bounce/App.vue +43 -0
  32. package/DemoForOperator/Bounce/Bounce.vue +81 -0
  33. package/DemoForOperator/Bounce/FreeMoveBuilder.js +139 -0
  34. package/DemoForOperator/ChunLian/App.vue +47 -0
  35. package/DemoForOperator/ChunLian/Couplets.vue +291 -0
  36. package/DemoForOperator/ClickSpriteAnim/App.vue +130 -0
  37. package/DemoForOperator/ClickSpriteAnim/Item.vue +74 -0
  38. package/DemoForOperator/DominantColor/App.vue +187 -0
  39. package/DemoForOperator/EpisodeList/App.vue +80 -0
  40. package/DemoForOperator/EpisodeList/EpisodeList/Controller.vue +110 -0
  41. package/DemoForOperator/EpisodeList/EpisodeList/EpisodeList.vue +250 -0
  42. package/DemoForOperator/EpisodeList/GroupItem.vue +65 -0
  43. package/DemoForOperator/EpisodeList/ListItem.vue +48 -0
  44. package/DemoForOperator/Firework1/App.vue +25 -0
  45. package/DemoForOperator/Firework1/Fireworks.vue +397 -0
  46. package/DemoForOperator/Firework1/SpriteDeal.js +30 -0
  47. package/DemoForOperator/FlipPage/App.vue +75 -0
  48. package/DemoForOperator/FlipPage/FlipPage/FlipPage.vue +178 -0
  49. package/DemoForOperator/FlipPage/FlipPage/flipIn.glsl +41 -0
  50. package/DemoForOperator/FlipPage/FlipPage/flipOut.glsl +41 -0
  51. package/DemoForOperator/Focus/Alpha/AlphaFocusBox.vue +95 -0
  52. package/DemoForOperator/Focus/Alpha/AlphaPage.vue +40 -0
  53. package/DemoForOperator/Focus/Alpha/Item.vue +64 -0
  54. package/DemoForOperator/Focus/App.vue +124 -0
  55. package/DemoForOperator/Focus/CommonPageSetting.js +30 -0
  56. package/DemoForOperator/Focus/Item.vue +46 -0
  57. package/DemoForOperator/Focus/Light/Item.vue +67 -0
  58. package/DemoForOperator/Focus/Light/LightFocusBox.vue +87 -0
  59. package/DemoForOperator/Focus/Light/LightPage.vue +43 -0
  60. package/DemoForOperator/Focus/Light/utils/FrameCanvasStore.ts +68 -0
  61. package/DemoForOperator/Focus/Light/utils/RotateFrame.vue +146 -0
  62. package/DemoForOperator/Focus/Light/utils/circleHaloMask.png +0 -0
  63. package/DemoForOperator/Focus/Normal/Item.vue +64 -0
  64. package/DemoForOperator/Focus/Normal/NormalFocusBox.vue +65 -0
  65. package/DemoForOperator/Focus/Normal/NormalPage.vue +41 -0
  66. package/DemoForOperator/Focus/SwipeLight/Item.vue +73 -0
  67. package/DemoForOperator/Focus/SwipeLight/SwipeLightBox.vue +62 -0
  68. package/DemoForOperator/Focus/SwipeLight/SwipeLightPage.vue +44 -0
  69. package/DemoForOperator/FrameShadow/App.vue +193 -0
  70. package/DemoForOperator/FrameShadow/FrameShadow.vue +61 -0
  71. package/DemoForOperator/FullscreenIn/App.vue +105 -0
  72. package/DemoForOperator/FullscreenIn/FullscreenPoster.vue +56 -0
  73. package/DemoForOperator/FullscreenIn/Item.vue +50 -0
  74. package/DemoForOperator/Genie/App.vue +78 -0
  75. package/DemoForOperator/Genie/geniePakcer/Genie.vue +741 -0
  76. package/DemoForOperator/Genie/geniePakcer/genieBottom.glsl +49 -0
  77. package/DemoForOperator/Genie/geniePakcer/genieLeft.glsl +50 -0
  78. package/DemoForOperator/Genie/geniePakcer/genieRight.glsl +57 -0
  79. package/DemoForOperator/Genie/geniePakcer/genieTop.glsl +50 -0
  80. package/DemoForOperator/GrayFilter/App.vue +51 -0
  81. package/DemoForOperator/GrayFilter/GrayFilter.vue +59 -0
  82. package/DemoForOperator/Jigsaw/App.vue +45 -0
  83. package/DemoForOperator/Jigsaw/JigsawFull.vue +142 -0
  84. package/DemoForOperator/Jigsaw/JigsawSingle.vue +118 -0
  85. package/DemoForOperator/LongChatBox/App.vue +36 -0
  86. package/DemoForOperator/LongChatBox/Bubble.vue +104 -0
  87. package/DemoForOperator/LongChatBox/LongChat.vue +173 -0
  88. package/DemoForOperator/LongChatBox/TextManager.ts +147 -0
  89. package/DemoForOperator/LongChatBox/VirtualList.vue +298 -0
  90. package/DemoForOperator/LongChatBox/testData.js +51 -0
  91. package/DemoForOperator/LongChatBox/utile.js +331 -0
  92. package/DemoForOperator/Particle/App.vue +69 -0
  93. package/DemoForOperator/Particle/Drop/DropParticle.vue +208 -0
  94. package/DemoForOperator/Particle/Explode/ExplodeParticle.vue +120 -0
  95. package/DemoForOperator/PosterAnim/App.vue +125 -0
  96. package/DemoForOperator/PosterAnim/Bounce/BouncePage.vue +54 -0
  97. package/DemoForOperator/PosterAnim/Bounce/Item.vue +85 -0
  98. package/DemoForOperator/PosterAnim/Breath/BreathPage.vue +47 -0
  99. package/DemoForOperator/PosterAnim/Breath/Item.vue +58 -0
  100. package/DemoForOperator/PosterAnim/CommonPageSetting.js +30 -0
  101. package/DemoForOperator/PosterAnim/Item.vue +46 -0
  102. package/DemoForOperator/PosterAnim/PosterAnim.js +79 -0
  103. package/DemoForOperator/PosterAnim/Scale/Item.vue +72 -0
  104. package/DemoForOperator/PosterAnim/Scale/ScalePage.vue +48 -0
  105. package/DemoForOperator/PosterAnim/Shake/Item.vue +85 -0
  106. package/DemoForOperator/PosterAnim/Shake/ShakePage.vue +53 -0
  107. package/DemoForOperator/PosterOverflow/App.vue +116 -0
  108. package/DemoForOperator/PosterOverflow/Item.vue +67 -0
  109. package/DemoForOperator/PosterOverflow/PosterOverflow.vue +39 -0
  110. package/DemoForOperator/Resize/App.vue +157 -0
  111. package/DemoForOperator/Resize/Resize/Item.vue +234 -0
  112. package/DemoForOperator/Resize/Resize/Resize.vue +96 -0
  113. package/DemoForOperator/Ripple/App.vue +54 -0
  114. package/DemoForOperator/Ripple/Ripple.vue +65 -0
  115. package/DemoForOperator/ScreenShootScale/App.vue +96 -0
  116. package/DemoForOperator/ScreenShootScale/Back.vue +86 -0
  117. package/DemoForOperator/ScreenShootScale/Front.vue +133 -0
  118. package/DemoForOperator/ScreenShootScale/Item.vue +62 -0
  119. package/DemoForOperator/ScreenShootScale/ScreenShootScale.vue +109 -0
  120. package/DemoForOperator/SmoothSwiper/App.vue +50 -0
  121. package/DemoForOperator/Sound/Bounce/App.vue +56 -0
  122. package/DemoForOperator/Sound/Bounce/Bounce.vue +87 -0
  123. package/DemoForOperator/Sound/Bounce/FreeMoveBuilder.js +146 -0
  124. package/DemoForOperator/Sound/Bounce/bgmusic.mp3 +0 -0
  125. package/DemoForOperator/Sound/Bounce/coin.mp3 +0 -0
  126. package/DemoForOperator/Sound/FocusMove/App.vue +134 -0
  127. package/DemoForOperator/Sound/FocusMove/Item.vue +43 -0
  128. package/DemoForOperator/Sound/FocusMove/move.mp3 +0 -0
  129. package/DemoForOperator/Sound/Rain/App.vue +11 -0
  130. package/DemoForOperator/Sound/Rain/Raining/Rain.vue +69 -0
  131. package/DemoForOperator/Sound/Rain/Raining/RainScene.vue +118 -0
  132. package/DemoForOperator/Sound/Sound/Sound.vue +24 -0
  133. package/DemoForOperator/Sound/Sound/index.js +4 -0
  134. package/DemoForOperator/Sound/Sound/useSound.js +112 -0
  135. package/DemoForOperator/Sprite/App.vue +33 -0
  136. package/DemoForOperator/Sprite/Sprite.vue +147 -0
  137. package/DemoForOperator/Stretch/App.vue +103 -0
  138. package/DemoForOperator/Stretch/Stretch/Item.vue +192 -0
  139. package/DemoForOperator/Stretch/Stretch/Stretch.vue +218 -0
  140. package/DemoForOperator/Swiper/App.vue +101 -0
  141. package/DemoForOperator/Swiper/Item.vue +56 -0
  142. package/DemoForOperator/Swiper/ParallaxSlide.vue +164 -0
  143. package/DemoForOperator/TabContent/App.vue +89 -0
  144. package/DemoForOperator/TabContent/ContentPage.vue +66 -0
  145. package/DemoForOperator/TabContent/Item.vue +85 -0
  146. package/DemoForOperator/TabContent/PageItem.vue +40 -0
  147. package/DemoForOperator/TabContent/TabContent/CreepFocus.vue +160 -0
  148. package/DemoForOperator/TabContent/TabContent/Item.vue +63 -0
  149. package/DemoForOperator/TabContent/TabContent/TabContent.vue +184 -0
  150. package/DemoForOperator/TabContent/TabContent/TabItem.vue +368 -0
  151. package/DemoForOperator/TabContent/TabContent/TabWidget.vue +243 -0
  152. package/DemoForOperator/TabContent/TabContent/Util.js +3 -0
  153. package/DemoForOperator/TabContent/TabContent/ViewSwiper.vue +110 -0
  154. package/DemoForOperator/TabContent/testData.js +241 -0
  155. package/DemoForOperator/TabContentVertical/App.vue +104 -0
  156. package/DemoForOperator/TabContentVertical/ContentPage.vue +67 -0
  157. package/DemoForOperator/TabContentVertical/Item.vue +94 -0
  158. package/DemoForOperator/TabContentVertical/PageItem.vue +40 -0
  159. package/DemoForOperator/TabContentVertical/TabContent/CreepFocus.vue +160 -0
  160. package/DemoForOperator/TabContentVertical/TabContent/Item.vue +63 -0
  161. package/DemoForOperator/TabContentVertical/TabContent/TabContent.vue +184 -0
  162. package/DemoForOperator/TabContentVertical/TabContent/TabItem.vue +368 -0
  163. package/DemoForOperator/TabContentVertical/TabContent/TabWidget.vue +259 -0
  164. package/DemoForOperator/TabContentVertical/TabContent/Util.js +3 -0
  165. package/DemoForOperator/TabContentVertical/TabContent/ViewSwiper.vue +110 -0
  166. package/DemoForOperator/TabContentVertical/assets/children_science.png +0 -0
  167. package/DemoForOperator/TabContentVertical/assets/documentary.png +0 -0
  168. package/DemoForOperator/TabContentVertical/assets/free.png +0 -0
  169. package/DemoForOperator/TabContentVertical/assets/game.png +0 -0
  170. package/DemoForOperator/TabContentVertical/assets/home_selected.png +0 -0
  171. package/DemoForOperator/TabContentVertical/assets/movie_ticket.png +0 -0
  172. package/DemoForOperator/TabContentVertical/assets/my_account.png +0 -0
  173. package/DemoForOperator/TabContentVertical/assets/opera.png +0 -0
  174. package/DemoForOperator/TabContentVertical/assets/sports.png +0 -0
  175. package/DemoForOperator/TabContentVertical/assets/tv_drama.png +0 -0
  176. package/DemoForOperator/TabContentVertical/assets/variety_show.png +0 -0
  177. package/DemoForOperator/TabContentVertical/assets/vip.png +0 -0
  178. package/DemoForOperator/TabContentVertical/testData.js +76 -0
  179. package/DemoForOperator/Vortex/App.vue +78 -0
  180. package/DemoForOperator/Vortex/Vortex/Vortex.vue +180 -0
  181. package/DemoForOperator/Vortex/Vortex/vortexIn.glsl +38 -0
  182. package/DemoForOperator/Vortex/Vortex/vortexOut.glsl +38 -0
  183. package/DemoForOperator/index.js +6 -0
  184. package/DemoForOperator/routeList.js +259 -0
  185. package/DemoHomepage/App.vue +50 -30
  186. package/DemoHomepage/components/Dialog.vue +1 -0
  187. package/DemoHomepage/components/Item.vue +11 -0
  188. package/DemoHomepage/components/TabFrame.vue +7 -0
  189. package/DemoHomepage/router.js +178 -81
  190. package/DemoHomepage/views/Homepage.vue +7 -2
  191. package/DivMetroPerformance/data.js +3 -3
  192. package/DriftScopeTest/App.vue +1 -1
  193. package/FilterDemo/AnimatePic.vue +1 -1
  194. package/FilterDemo/VideoLayer.vue +2 -2
  195. package/FullScreenFlex/TestFrame2.vue +1 -1
  196. package/GiftRain/App.vue +12 -12
  197. package/GiftRain/components/SpriteTranslate.vue +68 -48
  198. package/HashHistory/App.vue +2 -2
  199. package/HashHistory/router.js +1 -1
  200. package/JsvPreDownloader/App.vue +4 -4
  201. package/MediaDemo/components/frames/AudioFrame.vue +1 -1
  202. package/MediaDemo/components/frames/VideoFrame.vue +1 -1
  203. package/MetroWidgetDemos/MassiveItems/ContentItem.vue +1 -1
  204. package/MetroWidgetDemos/MassiveItems/data.js +1 -1
  205. package/MetroWidgetDemos/PerformanceTest/data.js +3 -3
  206. package/MetroWidgetDemos/RefreshDemo/assets/imageList.json +235 -235
  207. package/MetroWidgetDemos/SkeletonDiagram/assets/imageList.json +235 -235
  208. package/MetroWidgetDemos/TripleWidget/App.vue +7 -1
  209. package/MetroWidgetDemos/TripleWidget/Item.vue +16 -2
  210. package/MetroWidgetDemos/TripleWidget/SWidgetItem.vue +7 -1
  211. package/MetroWidgetDemos/TripleWidget/WidgetItem.vue +8 -2
  212. package/MetroWidgetDemos/focusableItemMetroWidget/WidgetItem.vue +3 -1
  213. package/MetroWidgetDemos/routeList.js +34 -17
  214. package/Poster3d/App.vue +69 -0
  215. package/Poster3d/Poster3d.vue +92 -0
  216. package/PosterPacker/App.vue +5 -5
  217. package/PosterPacker/tools/vortexPacker/Vortex.vue +1 -1
  218. package/QrcodeDemo/App.vue +1 -1
  219. package/Ripple/App.vue +1 -1
  220. package/ScaleDownNeon/App.vue +4 -4
  221. package/SceneTransition/App.vue +2 -2
  222. package/SceneTransition/maskConfig/config2.js +12 -12
  223. package/SceneTransition/maskConfig/config3.js +14 -14
  224. package/SprayView/App.vue +96 -51
  225. package/SpringFestival/App.vue +73 -0
  226. package/SpringFestival/SpringFestivalScene/ChunLian.vue +211 -0
  227. package/SpringFestival/SpringFestivalScene/FreeMoveBuilder.js +139 -0
  228. package/SpringFestival/SpringFestivalScene/LanternAnim.js +60 -0
  229. package/SpringFestival/SpringFestivalScene/Rain.vue +137 -0
  230. package/SpringFestival/SpringFestivalScene/Scene.vue +218 -0
  231. package/SpringFestival/SpringFestivalScene/imageConfig.js +87 -0
  232. package/SpringFestival/SpringFestivalScene/index.js +1 -0
  233. package/Swiper/App.vue +28 -29
  234. package/Swiper/Item.vue +19 -0
  235. package/SwiperTest/App.vue +9 -9
  236. package/TestNativeSharedView/AckEventDefine.ts +82 -0
  237. package/TestNativeSharedView/App.vue +4 -6
  238. package/TestNativeSharedView/JsvDemoTester.js +131 -0
  239. package/TextureAnimation/App.vue +16 -6
  240. package/TextureAnimation/App3.vue +100 -0
  241. package/TextureAnimation/utils/FrameCanvasStore.ts +68 -0
  242. package/TextureAnimation/utils/RotateFrame.vue +146 -0
  243. package/TextureAnimation/utils/circleHaloMask.png +0 -0
  244. package/TombSweepingDayTest/Raining/RainScene.vue +4 -4
  245. package/ViewOpacity/App.vue +21 -2
  246. package/package.json +1 -1
@@ -0,0 +1,368 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-08 14:52:17
4
+ * @Description: file content
5
+ -->
6
+ <script setup>
7
+ import { ref, inject, shallowRef, provide, computed } from "vue";
8
+ import {
9
+ ListWidget,
10
+ HORIZONTAL,
11
+ useFocusHub,
12
+ getKeyFramesGroup,
13
+ EdgeDirection,
14
+ } from "jsview";
15
+ import Item from "./Item.vue";
16
+ import CreepFocus from "./CreepFocus.vue";
17
+ import { getTouchFlag } from "./Util.js";
18
+
19
+ const tabFocus = inject("tabFocus");
20
+
21
+ const touchFlag = getTouchFlag();
22
+ const globalInfo = inject("globalInfo");
23
+ const modeIsKey = inject("modeIsKey");
24
+ const DURATION = 200;
25
+ const props = defineProps({
26
+ data: Object,
27
+ query: Object,
28
+ onAction: Object,
29
+ onItemEdge: Function,
30
+ onItemFocus: Function,
31
+ onItemClick: Function,
32
+ creepFocusColor: String,
33
+ });
34
+ const focusHub = useFocusHub();
35
+ const folded = ref(true);
36
+ const creepFocus = ref(null);
37
+ const showFocus = ref(true);
38
+ const styleShell = getKeyFramesGroup();
39
+ const itemKeepScale = ref(false);
40
+ provide("itemKeepScale", itemKeepScale);
41
+
42
+ const keepOpen = ref(false);
43
+ const focused = ref(false);
44
+ const width = ref(props.data.width);
45
+ const widgetRef = shallowRef(null);
46
+ const widgetLeft = ref(0);
47
+ const customCallbacks = {};
48
+ const selfOnAction = {
49
+ register: (name, func) => {
50
+ customCallbacks[name] = func;
51
+ },
52
+ unregister: (name) => {
53
+ delete customCallbacks[name];
54
+ },
55
+ };
56
+
57
+ const focusRectController = {
58
+ onFocusChange: (rect) => {
59
+ creepFocus.value?.changeRect(rect);
60
+ },
61
+ };
62
+ const focusFrameController = inject("focusFrameController");
63
+
64
+ const provideData = () => {
65
+ return props.data.childTab.list;
66
+ };
67
+
68
+ const measures = (data) => {
69
+ return {
70
+ width: data.width,
71
+ height: data.height,
72
+ marginRight: data.marginRight,
73
+ enableTap: touchFlag == 1,
74
+ };
75
+ };
76
+ const openTab = () => {
77
+ itemKeepScale.value = false;
78
+ showFocus.value = true;
79
+ widgetLeft.value = 0;
80
+ folded.value = false;
81
+ width.value = props.data.childTab.width;
82
+ //为了居中而计算锚点
83
+ const anchor = getAnchor(0);
84
+ //创建动画
85
+ const anim = getClipAnimation(props.data.width, width.value, anchor);
86
+ clipAnimStr.value = anim.clip;
87
+ slideAnimStr.value = anim.slide;
88
+
89
+ props.query.updateItemSize(
90
+ props.query.index,
91
+ {
92
+ width: width.value,
93
+ height: props.data.height,
94
+ },
95
+ {
96
+ anchor,
97
+ duration: DURATION,
98
+ onEnd: () => {
99
+ console.log("unfold anim end.");
100
+ },
101
+ }
102
+ );
103
+ focusHub.setFocus(props.data.name);
104
+ focusFrameController.focusVisible(false);
105
+ if (!modeIsKey()) {
106
+ props.onItemClick(null, onBlur);
107
+ }
108
+ };
109
+
110
+ // 注册回调
111
+ const onFocus = () => {
112
+ console.log("onFocus", focused.value);
113
+ if (!keepOpen.value) {
114
+ focusFrameController.focusVisible(true);
115
+ folded.value = true;
116
+ props.onItemFocus(props.data, onBlur);
117
+ } else {
118
+ focusHub.setFocus(props.data.name);
119
+ // folded.value = false;
120
+ }
121
+ focused.value = true;
122
+ if (folded.value && props.data.childTab) {
123
+ openTab();
124
+ } else {
125
+ keepOpen.value = false;
126
+ }
127
+ customCallbacks.onFocus?.();
128
+ };
129
+
130
+ const onItemFocus = (data) => {
131
+ focusFrameController.focusVisible(false);
132
+ showFocus.value = true;
133
+ props.onItemFocus(data);
134
+ };
135
+
136
+ const foldSubTab = () => {
137
+ if (!folded.value) {
138
+ if (width.value == props.data.childTab.width) {
139
+ width.value = props.data.width;
140
+ let index = widgetRef.value?.getCurrentFocusIndex() ?? 0;
141
+
142
+ const anchor = getAnchor(index);
143
+ widgetLeft.value = -Math.round(
144
+ (props.data.childTab.width - props.data.width) * anchor
145
+ );
146
+
147
+ //创建动画
148
+ const anim = getClipAnimation(
149
+ props.data.childTab.width,
150
+ width.value,
151
+ anchor
152
+ );
153
+ clipAnimStr.value = anim.clip;
154
+ slideAnimStr.value = anim.slide;
155
+
156
+ props.query.updateItemSize(
157
+ props.query.index,
158
+ {
159
+ width: width.value,
160
+ height: props.data.height,
161
+ },
162
+ {
163
+ duration: DURATION,
164
+ onEnd: () => {
165
+ focusFrameController.focusVisible(true);
166
+ folded.value = true;
167
+ },
168
+ }
169
+ );
170
+ }
171
+ focusHub.returnFocusToParent();
172
+ }
173
+ };
174
+
175
+ const onBlur = () => {
176
+ customCallbacks.onBlur?.();
177
+ if (!itemKeepScale.value) {
178
+ showFocus.value = false;
179
+ }
180
+ if (keepOpen.value) {
181
+ return;
182
+ }
183
+ focused.value = false;
184
+ };
185
+
186
+ let animToken = 1;
187
+ const clipAnimStr = ref("");
188
+ const slideAnimStr = ref("");
189
+ const animationCache = {};
190
+ const getClipAnimation = (from, to, anchor) => {
191
+ animToken++;
192
+ const name = "foldableItemClipAnim" + animToken;
193
+ if (animationCache.hasOwnProperty(name)) {
194
+ styleShell.removeRule(name);
195
+ delete animationCache[name];
196
+ }
197
+ const clipAnimStr = `@keyframes ${name} { from { width: ${from}; } to { width: ${to}; } }`;
198
+ animationCache[name] = clipAnimStr;
199
+ styleShell.insertRule(clipAnimStr);
200
+
201
+ //平移动画
202
+ const anchorPosition = Math.round((to - from) * anchor);
203
+ const slideName = "foldableItemSlideAnim" + animToken;
204
+ if (animationCache.hasOwnProperty(slideName)) {
205
+ styleShell.removeRule(slideName);
206
+ delete animationCache[slideName];
207
+ }
208
+ const slideAnimStr = `@keyframes ${slideName} { from { transform: translate3d(${-anchorPosition},0,0); } to { transform: translate3d(0,0,0); } }`;
209
+
210
+ animationCache[slideName] = slideAnimStr;
211
+ styleShell.insertRule(slideAnimStr);
212
+
213
+ return {
214
+ clip: `${name} ${DURATION / 1000}s`,
215
+ slide: `${slideName} ${DURATION / 1000}s`,
216
+ };
217
+ };
218
+
219
+ const getAnchor = (index) => {
220
+ let anchor = 0;
221
+ const l = props.data.childTab.list;
222
+ if (index <= 0) {
223
+ anchor = 0;
224
+ } else if (index > l.length - 1) {
225
+ anchor = 1;
226
+ } else {
227
+ let focusMiddle = 0;
228
+ for (let i = 0; i <= index - 1; ++i) {
229
+ focusMiddle += l[i].width + l[i].marginRight;
230
+ }
231
+ focusMiddle += l[index].width / 2;
232
+ const scaleRate = props.data.childTab.width / props.data.width;
233
+ const targetPercent = focusMiddle / props.data.childTab.width; // 居中目标位置的百分比
234
+ /**
235
+ * anchor计算说明
236
+ * 考虑[0,1]的线段, 以a(0 <= a <= 1)为锚点, 放大n倍(n > 1)
237
+ * 坐标的映射关系为 x -> n(x - a) + a
238
+ * 此处我们想要的是目标焦点的中线对齐0.5, 即targetPercent放大后的位置是0.5
239
+ * 所以方程为 scaleRate * (targetPercent - anchor) + anchor = 0.5
240
+ */
241
+ anchor = (scaleRate * targetPercent - 0.5) / (scaleRate - 1);
242
+ }
243
+ return anchor;
244
+ };
245
+
246
+ const onClick = () => {
247
+ if (folded.value && props.data.childTab) {
248
+ openTab();
249
+ } else {
250
+ if (!modeIsKey()) {
251
+ props.onItemClick(props.data, onBlur, onFocus);
252
+ }
253
+ }
254
+ customCallbacks.onClick?.();
255
+ };
256
+
257
+ console.log("tabitem", props.data, props.onAction);
258
+ props.onAction.register("onFocus", onFocus);
259
+ props.onAction.register("onBlur", onBlur);
260
+ props.onAction.register("onClick", onClick);
261
+
262
+ const onKeyDown = (ev) => {
263
+ if (ev.keyCode === 10000 || ev.keyCode === 8 || ev.keyCode === 27) {
264
+ keepOpen.value = true;
265
+ // itemKeepScale.value = false;
266
+ // foldSubTab();
267
+ }
268
+ return false;
269
+ };
270
+ const onItemEdge = (edgeInfo) => {
271
+ if (
272
+ edgeInfo.direction == EdgeDirection.top ||
273
+ edgeInfo.direction == EdgeDirection.bottom
274
+ ) {
275
+ keepOpen.value = true;
276
+ } else {
277
+ foldSubTab();
278
+ }
279
+ props.onItemEdge(edgeInfo);
280
+ };
281
+ const onItemClick2 = (data) => {
282
+ // widgetRef.value.setFocusId(data.tabIndex);
283
+ };
284
+ const isSlect = computed(() => {
285
+ if (modeIsKey()) {
286
+ return (
287
+ !tabFocus.value &&
288
+ !focused.value &&
289
+ globalInfo.updateTabId == props.data.indexId
290
+ );
291
+ } else {
292
+ return globalInfo.updateTabId == props.data.indexId;
293
+ }
294
+ });
295
+ </script>
296
+
297
+ <template>
298
+ <slot
299
+ v-if="folded"
300
+ name="tabItem"
301
+ :data="data"
302
+ :onAction="selfOnAction"
303
+ :query="query"
304
+ ></slot>
305
+ <div
306
+ v-else
307
+ :style="{
308
+ width: width,
309
+ height: data.height,
310
+ overflow: 'hidden',
311
+ animation: clipAnimStr,
312
+ }"
313
+ >
314
+ <jsv-focus-block
315
+ v-if="data.childTab"
316
+ :onAction="{
317
+ onKeyDown,
318
+ }"
319
+ :style="{
320
+ left: widgetLeft,
321
+ width: data.childTab.width - 10,
322
+ height: data.height,
323
+ animation: slideAnimStr,
324
+ }"
325
+ >
326
+ <list-widget
327
+ ref="widgetRef"
328
+ :name="data.name"
329
+ :width="data.childTab.width"
330
+ :height="data.height"
331
+ :provideData="provideData"
332
+ :direction="HORIZONTAL"
333
+ :measures="measures"
334
+ :onEdge="onItemEdge"
335
+ :initFocusId="0"
336
+ :touchFlag="touchFlag"
337
+ >
338
+ <template #renderItem="{ data, onAction, query }">
339
+ <item
340
+ :focusRectController="focusRectController"
341
+ :data="data"
342
+ :onAction="onAction"
343
+ :query="query"
344
+ :onItemFocus="onItemFocus"
345
+ :onItemClick="onItemClick2"
346
+ >
347
+ <template #tabItem="{ data, onAction, query }">
348
+ <slot
349
+ name="tabItem"
350
+ :data="data"
351
+ :query="query"
352
+ :onAction="onAction"
353
+ ></slot>
354
+ </template>
355
+ </item>
356
+ </template>
357
+ <template #background>
358
+ <creep-focus
359
+ v-show="showFocus && modeIsKey()"
360
+ ref="creepFocus"
361
+ :color="creepFocusColor"
362
+ >
363
+ </creep-focus>
364
+ </template>
365
+ </list-widget>
366
+ </jsv-focus-block>
367
+ </div>
368
+ </template>
@@ -0,0 +1,259 @@
1
+ <script setup>
2
+ import { onMounted, inject, ref, provide, shallowRef, computed } from "vue";
3
+ import {
4
+ getTextWidth,
5
+ ListWidget,
6
+ useFocusHub,
7
+ FixPositionSlide,
8
+ EdgeDirection,
9
+ HORIZONTAL,
10
+ VERTICAL,
11
+ } from "jsview";
12
+ import TabItem from "./TabItem.vue";
13
+ import CreepFocus from "./CreepFocus.vue";
14
+ import { getTouchFlag } from "./Util.js";
15
+
16
+ const touchFlag = getTouchFlag();
17
+ const modeIsKey = inject("modeIsKey");
18
+
19
+ const tabFocus = inject("tabFocus");
20
+ const focusHub = useFocusHub();
21
+ const props = defineProps({
22
+ data: Array,
23
+ name: String,
24
+ onEdge: Function,
25
+ layout: Object,
26
+ padding: Object,
27
+ itemGap: Number,
28
+ initFocusId: Number,
29
+ tabTextFontSize: Number,
30
+ creepFocusColor: String,
31
+ });
32
+ console.log("layout", props.layout);
33
+ const itemWidthExpand = 60;
34
+ const globalInfo = inject("globalInfo");
35
+ const slideType = new FixPositionSlide({duration: 200});
36
+
37
+ const creepFocus = ref(null);
38
+ const showFocus = ref(true);
39
+ let currentFocusRect = {};
40
+ const focusFrameController = {
41
+ focusVisible: (visible) => {
42
+ showFocus.value = visible ? true : false;
43
+ },
44
+ onFocusChange: (rect, focusIndex, doAnim) => {
45
+ creepFocus.value?.changeRect(rect, doAnim);
46
+ currentFocusRect = rect;
47
+ },
48
+ };
49
+ provide("focusFrameController", focusFrameController);
50
+ const itemHeight = computed(
51
+ () =>
52
+ props.layout.height -
53
+ (props.padding?.top ?? 0) -
54
+ (props.padding?.bottom ?? 0)
55
+ );
56
+
57
+ const itemWidth = computed(
58
+ () =>
59
+ props.layout.width -
60
+ (props.padding?.left ?? 0) -
61
+ (props.padding?.right ?? 0)
62
+ );
63
+
64
+ const SizeObj = {
65
+ fontSize: props.tabTextFontSize,
66
+ };
67
+ const data = [];
68
+ const getChildTabList = (childTab) => {
69
+ if (!childTab) {
70
+ return null;
71
+ }
72
+ const list = [];
73
+ for (let i = 0; i < childTab.length; ++i) {
74
+ const childTextSize = getTextWidth(childTab[i].itemTitle, SizeObj);
75
+ let obj = {
76
+ // width: childTextSize + itemWidthExpand,
77
+ // height: itemHeight.value,
78
+ width: itemWidth.value,
79
+ height: itemWidth.value,
80
+ marginRight: props.itemGap,
81
+ marginBottom: props.itemGap,
82
+ content: childTab[i].itemTitle,
83
+ index: i,
84
+ ...childTab[i],
85
+ };
86
+ list.push(obj);
87
+ }
88
+ return list;
89
+ };
90
+
91
+ for (let i = 0; i < props.data.length; ++i) {
92
+ const textSize = getTextWidth(props.data[i].itemTitle, SizeObj);
93
+ const childList = getChildTabList(props.data[i].childTab);
94
+ let totalWidth = 0;
95
+ if (childList) {
96
+ childList.forEach((item) => {
97
+ totalWidth += item.width + item.marginRight;
98
+ });
99
+ }
100
+ let obj = {
101
+ // width: textSize + itemWidthExpand,
102
+ // height: itemHeight.value,
103
+ width: itemWidth.value,
104
+ height: itemWidth.value,
105
+
106
+ content: props.data[i].itemTitle,
107
+ marginRight: props.itemGap,
108
+ marginBottom: props.itemGap,
109
+ name: "item_" + i, // focus name
110
+ ...props.data[i],
111
+ };
112
+ if (childList) {
113
+ obj.childTab = {
114
+ width: totalWidth,
115
+ list: childList,
116
+ };
117
+ }
118
+ data.push(obj);
119
+ }
120
+ const provideData = () => {
121
+ return data;
122
+ };
123
+
124
+ const measures = (item) => {
125
+ return {
126
+ width: item.width,
127
+ height: item.height,
128
+ marginRight: item.marginRight,
129
+ marginBottom: item.marginBottom,
130
+ enableTap: touchFlag == 1,
131
+ };
132
+ };
133
+
134
+ const widgetRef = shallowRef();
135
+ onMounted(() => {
136
+ provide("parentWidget", widgetRef);
137
+ });
138
+
139
+ const onFocusRectChange = () => {
140
+ //展开时的滑动不需要更新焦点大小
141
+ if (showFocus.value) {
142
+ const curFocusIndex = widgetRef.value.getCurrentFocusIndex();
143
+ const rect = widgetRef.value.getTemplatePosition(curFocusIndex);
144
+ focusFrameController.onFocusChange(rect, curFocusIndex);
145
+ }
146
+ };
147
+ const onAllResizeDone = () => {
148
+ console.log("onAllResizeDone");
149
+ };
150
+
151
+ const onItemFocus = (item_data, onBlur) => {
152
+ console.log("testtest onItemFocus", item_data);
153
+ globalInfo.tabId = item_data.indexId;
154
+ if (globalInfo.updateTabId == -1 || !modeIsKey()) {
155
+ globalInfo.updateTabId = item_data.indexId;
156
+ }
157
+ if (globalInfo.tabCode != item_data.itemCode) {
158
+ globalInfo.tabCode = item_data.itemCode;
159
+ // if (props.data.icon4) {
160
+ // changeBg(props.data.icon4);
161
+ // }
162
+ }
163
+ };
164
+
165
+ const onEdge = (edgeInfo) => {
166
+ props.onEdge(edgeInfo);
167
+ };
168
+
169
+ const onItemClick = (data, onBlur, onFocus) => {
170
+ // manager.onItemTap({ onBlur: onBlur, onFocus: onFocus });
171
+ // if (data) {
172
+ // focusHub.setFocus(props.name);
173
+ // widgetRef.value.setFocusId(data.index);
174
+ // }
175
+ };
176
+
177
+ const onBlur = () => {
178
+ showFocus.value = false;
179
+ tabFocus.value = false;
180
+ };
181
+
182
+ const onFocus = () => {
183
+ showFocus.value = true;
184
+ tabFocus.value = true;
185
+ };
186
+
187
+ // Manager 实现
188
+ const manager = {
189
+ previousItem: null,
190
+
191
+ // 注册 onBlur 方法
192
+ registerOnBlur(item) {
193
+ if (this.previousItem && this.previousItem.onBlur) {
194
+ this.previousItem.onBlur(); // 调用上一个 item 的 onBlur
195
+ }
196
+ if (item.onFocus) {
197
+ item.onFocus();
198
+ }
199
+ this.previousItem = item; // 更新上一个 item
200
+ },
201
+
202
+ // 处理 item 被点击
203
+ onItemTap(item) {
204
+ this.registerOnBlur(item);
205
+ },
206
+ };
207
+ </script>
208
+
209
+ <template>
210
+ <div :style="{ left: layout.left, top: layout.top }">
211
+ <list-widget
212
+ ref="widgetRef"
213
+ :name="name"
214
+ :onFocusRectChange="onFocusRectChange"
215
+ :onAllItemResizeDone="onAllResizeDone"
216
+ :width="layout.width"
217
+ :height="layout.height"
218
+ :slideSetting="slideType"
219
+ :direction="VERTICAL"
220
+ :provideData="provideData"
221
+ :measures="measures"
222
+ :padding="padding"
223
+ :initFocusId="initFocusId"
224
+ :onEdge="onEdge"
225
+ :onFocus="onFocus"
226
+ :onBlur="onBlur"
227
+ :touchFlag="touchFlag"
228
+ >
229
+ <template #renderItem="{ data, onAction, query, onItemEdge }">
230
+ <tab-item
231
+ :data="data"
232
+ :onAction="onAction"
233
+ :query="query"
234
+ :onItemEdge="onItemEdge"
235
+ :onItemFocus="onItemFocus"
236
+ :onItemClick="onItemClick"
237
+ :creepFocusColor="creepFocusColor"
238
+ >
239
+ <template #tabItem="{ data, onAction, query }">
240
+ <slot
241
+ name="tabItem"
242
+ :data="data"
243
+ :query="query"
244
+ :onAction="onAction"
245
+ ></slot>
246
+ </template>
247
+ </tab-item>
248
+ </template>
249
+ <template #background>
250
+ <creep-focus
251
+ v-show="showFocus && modeIsKey()"
252
+ ref="creepFocus"
253
+ :color="creepFocusColor"
254
+ >
255
+ </creep-focus>
256
+ </template>
257
+ </list-widget>
258
+ </div>
259
+ </template>
@@ -0,0 +1,3 @@
1
+ export function getTouchFlag() {
2
+ return 0;
3
+ }