@shijiu/jsview-vue-samples 2.3.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 (117) hide show
  1. package/DashPath/App.vue +17 -16
  2. package/DashPath/AppForOperator.vue +2 -4
  3. package/DemoForOperator/AnimPic/AnimPic.vue +24 -2
  4. package/DemoForOperator/Banger/Banger/Banger.vue +73 -9
  5. package/DemoForOperator/Blur/Blur.vue +146 -0
  6. package/DemoForOperator/Blur/BlurInOut/BlurInOut.vue +158 -0
  7. package/DemoForOperator/Blur/BlurInOut/StaticBgSlide.vue +162 -0
  8. package/DemoForOperator/Blur/BlurPopup/BlurPopup.vue +113 -0
  9. package/DemoForOperator/BookFlip/App.vue +115 -0
  10. package/DemoForOperator/BookFlip/BookFlip/FlipPage.vue +179 -0
  11. package/DemoForOperator/BookFlip/BookFlip/FlippingBook.vue +310 -0
  12. package/DemoForOperator/BookFlip/BookFlip/flip.glsl +135 -0
  13. package/DemoForOperator/BookFlip/BookPage.vue +82 -0
  14. package/DemoForOperator/Bounce/Bounce.vue +33 -1
  15. package/DemoForOperator/ChunLian/Couplets.vue +44 -1
  16. package/DemoForOperator/ClickSpriteAnim/App.vue +130 -0
  17. package/DemoForOperator/ClickSpriteAnim/Item.vue +74 -0
  18. package/DemoForOperator/DominantColor/App.vue +187 -0
  19. package/DemoForOperator/EpisodeList/EpisodeList/Controller.vue +0 -3
  20. package/DemoForOperator/EpisodeList/EpisodeList/EpisodeList.vue +76 -2
  21. package/DemoForOperator/Firework1/App.vue +1 -1
  22. package/DemoForOperator/Firework1/Fireworks.vue +50 -11
  23. package/DemoForOperator/FlipPage/FlipPage/FlipPage.vue +29 -1
  24. package/DemoForOperator/Focus/Alpha/AlphaFocusBox.vue +27 -2
  25. package/DemoForOperator/Focus/Light/LightFocusBox.vue +42 -1
  26. package/DemoForOperator/Focus/Normal/NormalFocusBox.vue +12 -0
  27. package/DemoForOperator/FrameShadow/App.vue +193 -0
  28. package/DemoForOperator/FrameShadow/FrameShadow.vue +61 -0
  29. package/DemoForOperator/FullscreenIn/App.vue +1 -1
  30. package/DemoForOperator/FullscreenIn/FullscreenPoster.vue +18 -3
  31. package/DemoForOperator/Genie/geniePakcer/Genie.vue +60 -18
  32. package/DemoForOperator/GrayFilter/GrayFilter.vue +21 -0
  33. package/DemoForOperator/Jigsaw/JigsawFull.vue +46 -4
  34. package/DemoForOperator/Jigsaw/JigsawSingle.vue +34 -2
  35. package/DemoForOperator/LongChatBox/App.vue +36 -0
  36. package/DemoForOperator/LongChatBox/Bubble.vue +104 -0
  37. package/DemoForOperator/LongChatBox/LongChat.vue +173 -0
  38. package/DemoForOperator/LongChatBox/TextManager.ts +147 -0
  39. package/DemoForOperator/LongChatBox/VirtualList.vue +298 -0
  40. package/DemoForOperator/LongChatBox/testData.js +51 -0
  41. package/DemoForOperator/LongChatBox/utile.js +331 -0
  42. package/DemoForOperator/Particle/Drop/DropParticle.vue +33 -1
  43. package/DemoForOperator/Particle/Explode/ExplodeParticle.vue +23 -2
  44. package/DemoForOperator/PosterAnim/PosterAnim.js +21 -0
  45. package/DemoForOperator/PosterOverflow/PosterOverflow.vue +16 -0
  46. package/DemoForOperator/Resize/App.vue +157 -0
  47. package/DemoForOperator/Resize/Resize/Item.vue +234 -0
  48. package/DemoForOperator/Resize/Resize/Resize.vue +96 -0
  49. package/DemoForOperator/Ripple/Ripple.vue +16 -1
  50. package/DemoForOperator/ScreenShootScale/App.vue +96 -0
  51. package/DemoForOperator/ScreenShootScale/Back.vue +86 -0
  52. package/DemoForOperator/ScreenShootScale/Front.vue +133 -0
  53. package/DemoForOperator/ScreenShootScale/Item.vue +62 -0
  54. package/DemoForOperator/ScreenShootScale/ScreenShootScale.vue +109 -0
  55. package/DemoForOperator/SmoothSwiper/App.vue +50 -0
  56. package/DemoForOperator/Sound/Bounce/App.vue +56 -0
  57. package/DemoForOperator/Sound/Bounce/Bounce.vue +87 -0
  58. package/DemoForOperator/Sound/Bounce/FreeMoveBuilder.js +146 -0
  59. package/DemoForOperator/Sound/Bounce/bgmusic.mp3 +0 -0
  60. package/DemoForOperator/Sound/Bounce/coin.mp3 +0 -0
  61. package/DemoForOperator/Sound/FocusMove/App.vue +134 -0
  62. package/DemoForOperator/Sound/FocusMove/Item.vue +43 -0
  63. package/DemoForOperator/Sound/FocusMove/move.mp3 +0 -0
  64. package/DemoForOperator/Sound/Rain/App.vue +11 -0
  65. package/DemoForOperator/Sound/Rain/Raining/Rain.vue +69 -0
  66. package/DemoForOperator/Sound/Rain/Raining/RainScene.vue +118 -0
  67. package/DemoForOperator/Sound/Sound/Sound.vue +24 -0
  68. package/DemoForOperator/Sound/Sound/index.js +4 -0
  69. package/DemoForOperator/Sound/Sound/useSound.js +112 -0
  70. package/DemoForOperator/Sprite/Sprite.vue +62 -5
  71. package/DemoForOperator/Stretch/Stretch/Stretch.vue +52 -2
  72. package/DemoForOperator/Swiper/App.vue +101 -0
  73. package/DemoForOperator/Swiper/Item.vue +56 -0
  74. package/DemoForOperator/Swiper/ParallaxSlide.vue +164 -0
  75. package/DemoForOperator/TabContent/TabContent/TabContent.vue +39 -1
  76. package/DemoForOperator/TabContentVertical/App.vue +104 -0
  77. package/DemoForOperator/TabContentVertical/ContentPage.vue +67 -0
  78. package/DemoForOperator/TabContentVertical/Item.vue +94 -0
  79. package/DemoForOperator/TabContentVertical/PageItem.vue +40 -0
  80. package/DemoForOperator/TabContentVertical/TabContent/CreepFocus.vue +160 -0
  81. package/DemoForOperator/TabContentVertical/TabContent/Item.vue +63 -0
  82. package/DemoForOperator/TabContentVertical/TabContent/TabContent.vue +184 -0
  83. package/DemoForOperator/TabContentVertical/TabContent/TabItem.vue +368 -0
  84. package/DemoForOperator/TabContentVertical/TabContent/TabWidget.vue +259 -0
  85. package/DemoForOperator/TabContentVertical/TabContent/Util.js +3 -0
  86. package/DemoForOperator/TabContentVertical/TabContent/ViewSwiper.vue +110 -0
  87. package/DemoForOperator/TabContentVertical/assets/children_science.png +0 -0
  88. package/DemoForOperator/TabContentVertical/assets/documentary.png +0 -0
  89. package/DemoForOperator/TabContentVertical/assets/free.png +0 -0
  90. package/DemoForOperator/TabContentVertical/assets/game.png +0 -0
  91. package/DemoForOperator/TabContentVertical/assets/home_selected.png +0 -0
  92. package/DemoForOperator/TabContentVertical/assets/movie_ticket.png +0 -0
  93. package/DemoForOperator/TabContentVertical/assets/my_account.png +0 -0
  94. package/DemoForOperator/TabContentVertical/assets/opera.png +0 -0
  95. package/DemoForOperator/TabContentVertical/assets/sports.png +0 -0
  96. package/DemoForOperator/TabContentVertical/assets/tv_drama.png +0 -0
  97. package/DemoForOperator/TabContentVertical/assets/variety_show.png +0 -0
  98. package/DemoForOperator/TabContentVertical/assets/vip.png +0 -0
  99. package/DemoForOperator/TabContentVertical/testData.js +76 -0
  100. package/DemoForOperator/Vortex/Vortex/Vortex.vue +26 -0
  101. package/DemoForOperator/routeList.js +118 -1
  102. package/DemoHomepage/components/Item.vue +11 -0
  103. package/DemoHomepage/router.js +75 -1
  104. package/GiftRain/components/SpriteTranslate.vue +68 -48
  105. package/HashHistory/App.vue +2 -2
  106. package/HashHistory/router.js +1 -1
  107. package/MetroWidgetDemos/TripleWidget/App.vue +7 -1
  108. package/MetroWidgetDemos/TripleWidget/Item.vue +16 -2
  109. package/MetroWidgetDemos/TripleWidget/SWidgetItem.vue +7 -1
  110. package/MetroWidgetDemos/TripleWidget/WidgetItem.vue +8 -2
  111. package/MetroWidgetDemos/routeList.js +17 -0
  112. package/PosterPacker/App.vue +2 -2
  113. package/ViewOpacity/App.vue +19 -0
  114. package/package.json +1 -1
  115. package/DashPath/DashPath.vue +0 -118
  116. package/DemoForOperator/ScalePoster/App.vue +0 -4
  117. package/DemoForOperator/ScalePoster/ScalePoster.vue +0 -0
@@ -0,0 +1,69 @@
1
+ <template>
2
+ <JsvFreeMoveActor
3
+ :top="-myHeight"
4
+ :left="myLeft"
5
+ :width="2"
6
+ :height="myHeight"
7
+ ref="myRef"
8
+ >
9
+ <div
10
+ :style="{
11
+ width: 2,
12
+ height: myHeight,
13
+ backgroundImage: `jsvtexturestore://${sourceId}`,
14
+ }"
15
+ ></div>
16
+ </JsvFreeMoveActor>
17
+ </template>
18
+
19
+ <script setup>
20
+ import { shallowRef, onBeforeUnmount, onMounted } from "vue";
21
+ import { JsvTextureStoreApi, JsvFreeMoveActor } from "jsview";
22
+ let canvasRef;
23
+ let sourceId = shallowRef("");
24
+ const canvasTexture = JsvTextureStoreApi.canvasTexture(10, 200);
25
+ canvasTexture.drawLine(0, 0, 0, 200, 10, "rgba(255, 255, 255, 0.5)");
26
+ canvasRef = canvasTexture.commit();
27
+ sourceId.value = canvasRef;
28
+ //随机长度函数(限制在80-160)
29
+ const randomHeight = () => {
30
+ return Math.floor(Math.random() * 80) + 80;
31
+ };
32
+
33
+ //随机left值
34
+ const randomLeft = () => {
35
+ return Math.floor(Math.random() * 1280);
36
+ };
37
+ const myHeight = randomHeight();
38
+ const myLeft = randomLeft();
39
+
40
+ let myRef = shallowRef(null);
41
+ let myControl;
42
+ let randomInteger = Math.floor(Math.random() * 200) + 1;
43
+
44
+ onMounted(() => {
45
+ myControl = myRef.value.control;
46
+ myControl.run((cmds) => [
47
+ cmds
48
+ .condition()
49
+ .onNextTick(randomInteger)
50
+ .then([
51
+ cmds.action().setSpeed(undefined, 9),
52
+ cmds.action(3).setAccel(undefined, 0.13),
53
+ ]),
54
+ cmds
55
+ .condition(undefined, true)
56
+ .reachPosition(undefined, 620)
57
+ .then([
58
+ cmds.action().teleportTo(undefined, -580 - myHeight),
59
+ cmds.action().setSpeed(undefined, 9),
60
+ cmds.action(3).setAccel(undefined, 0.13),
61
+ ]),
62
+ ]);
63
+ });
64
+ onBeforeUnmount(() => {
65
+ JsvTextureStoreApi.deleteTexture(sourceId.value);
66
+ });
67
+ </script>
68
+
69
+ <style lang="scss" scoped></style>
@@ -0,0 +1,118 @@
1
+ <template>
2
+ <JsvRipple :width="1280" :height="720" ref="rippleViewRef">
3
+ <jsv-focus-block autoFocus>
4
+ <img
5
+ :src="bg"
6
+ :style="{ width: 1280, height: 720 }"
7
+ :onLoad="funcBackgroundOnLoaded"
8
+ />
9
+ <div
10
+ :style="{
11
+ width: 100,
12
+ height: 100,
13
+ backgroundImage: title,
14
+ left: 900,
15
+ top: 40,
16
+ }"
17
+ ></div>
18
+ <!-- 随机位置和长度的雨滴 -->
19
+ <Rain v-for="(item, index) in 60" />
20
+ <!-- 波纹效果 -->
21
+ </jsv-focus-block>
22
+ </JsvRipple>
23
+ <Sound :bgInfos="bgInfos" />
24
+ </template>
25
+
26
+ <script setup>
27
+ import Rain from "./Rain.vue";
28
+ import { JsvRipple, JsvRippleShape } from "jsview";
29
+ import { shallowRef, onMounted, onBeforeUnmount } from "vue";
30
+ import { useSound, Sound } from "../../Sound";
31
+
32
+ const bg =
33
+ "https://cdn.release.qcast.cn/JsViewFrameworkTester/JsViewVueSampleResources/TombSweepingDayTest/Raining/RainScene/qingming_bg.jpg";
34
+ const title =
35
+ "https://cdn.release.qcast.cn/JsViewFrameworkTester/JsViewVueSampleResources/TombSweepingDayTest/Raining/RainScene/qingming_title.png";
36
+ const musicBg =
37
+ "https://cdn.release.qcast.cn/JsViewFrameworkTester/JsViewVueSampleResources/TombSweepingDayTest/Raining/RainScene/rain_background.mp3";
38
+ const mySound =
39
+ "https://cdn.release.qcast.cn/JsViewFrameworkTester/JsViewVueSampleResources/TombSweepingDayTest/Raining/RainScene/rain_tiktok.mp3";
40
+
41
+ const { playSfx, playBg, pauseBg, bgInfos } = useSound(
42
+ {
43
+ bg: {
44
+ url: musicBg,
45
+ onLoad: () => {
46
+ console.log("bg onLoad");
47
+ playBg("bg");
48
+ },
49
+ },
50
+ },
51
+ { rain: mySound }
52
+ );
53
+
54
+ let timer = { id: -1, id2: -1 };
55
+ let rippleViewRef = shallowRef(null);
56
+ const genSource = () => {
57
+ let leftOrRight = Math.random() >= 0.5 ? true : false;
58
+ if (leftOrRight) {
59
+ return [
60
+ Math.floor(Math.random() * (336 - 214 + 1)) + 214,
61
+ Math.round(Math.random() * 200 + 400),
62
+ Math.round(Math.random() * 100 + 20),
63
+ ];
64
+ } else {
65
+ return [
66
+ Math.floor(Math.random() * (1066 - 960 + 1)) + 960,
67
+ Math.round(Math.random() * 200 + 400),
68
+ Math.round(Math.random() * 100 + 20),
69
+ ];
70
+ }
71
+ };
72
+
73
+ let backgrounLoaded = false;
74
+ const funcBackgroundOnLoaded = () => {
75
+ backgrounLoaded = true;
76
+ console.log("bg image loaded");
77
+ };
78
+
79
+ onMounted(() => {
80
+ if (rippleViewRef.value !== null) {
81
+ timer.id = setInterval(() => {
82
+ if (backgrounLoaded) {
83
+ // 图片加载完成后再追加波纹,规避绘出黑色的波圈
84
+ const p = genSource();
85
+ rippleViewRef.value.addSource(
86
+ ...p,
87
+ {
88
+ type: JsvRippleShape.CIRCLE,
89
+ },
90
+ {
91
+ timeDecay: 0.5,
92
+ distanceDecay: 8,
93
+ speed: 60,
94
+ frequency: 2,
95
+ waveNum: 2,
96
+ }
97
+ );
98
+
99
+ timer.id2 = setTimeout(() => {
100
+ playSfx("rain");
101
+ }, 1000);
102
+ }
103
+ }, 3000);
104
+ }
105
+ });
106
+ onBeforeUnmount(() => {
107
+ if (timer.id !== -1) {
108
+ clearInterval(timer.id);
109
+ timer.id = -1;
110
+ }
111
+ if (timer.id2 !== -1) {
112
+ clearTimeout(timer.id2);
113
+ timer.id2 = -1;
114
+ }
115
+ });
116
+ </script>
117
+
118
+ <style scoped></style>
@@ -0,0 +1,24 @@
1
+ <script setup>
2
+ import { JsvAudio } from "jsview";
3
+
4
+ const props = defineProps({
5
+ bgInfos: {
6
+ type: Object,
7
+ default: () => {},
8
+ },
9
+ });
10
+ console.log("bgInfos", props.bgInfos);
11
+ </script>
12
+
13
+ <template>
14
+ <div>
15
+ <jsv-audio
16
+ v-for="(bgInfo, index) in bgInfos"
17
+ :key="index"
18
+ :onRef="bgInfo.onRef"
19
+ :onLoad="bgInfo.onLoad"
20
+ :src="bgInfo.url"
21
+ :loop="true"
22
+ />
23
+ </div>
24
+ </template>
@@ -0,0 +1,4 @@
1
+ import { useSound } from "./useSound";
2
+ import Sound from "./Sound.vue";
3
+
4
+ export { useSound, Sound };
@@ -0,0 +1,112 @@
1
+ import { onMounted, onBeforeUnmount } from "vue";
2
+ import { JsvSoundPool, globalLoadJsvAudioPlugin } from "jsview";
3
+
4
+ let jsvAudioLoaded = false;
5
+ const safeLoadJsvAudio = () => {
6
+ if (!jsvAudioLoaded) {
7
+ globalLoadJsvAudioPlugin((status) => {
8
+ console.log("load JsvAudio plugin status", status);
9
+ if (status == 4) {
10
+ jsvAudioLoaded = true;
11
+ }
12
+ });
13
+ }
14
+ };
15
+
16
+ export function useSound(bgSourceMap, sfxSourceMap, needRepeat = false) {
17
+ let sfxController = {};
18
+ let bgController = {};
19
+
20
+ let soundPool = null;
21
+ const loadSfx = (sfxMap) => {
22
+ soundPool = new JsvSoundPool(10);
23
+ for (const [key, value] of Object.entries(sfxMap)) {
24
+ if (needRepeat) {
25
+ soundPool.requestInRepeatMode(
26
+ `url(${value})`,
27
+ 100,
28
+ null,
29
+ 1,
30
+ (state, audioController) => {
31
+ if (state === 0) {
32
+ sfxController[key] = audioController;
33
+ }
34
+ }
35
+ );
36
+ } else {
37
+ soundPool.request(
38
+ `url(${value})`,
39
+ null,
40
+ 1,
41
+ (state, audioController) => {
42
+ if (state === 0) {
43
+ sfxController[key] = audioController;
44
+ }
45
+ }
46
+ );
47
+ }
48
+ }
49
+ };
50
+ if (sfxSourceMap && Object.keys(sfxSourceMap).length > 0) {
51
+ loadSfx(sfxSourceMap);
52
+ }
53
+
54
+ const initBg = (bgMap) => {
55
+ if (!bgMap) return [];
56
+ const bgInfos = [];
57
+ for (const [key, value] of Object.entries(bgMap)) {
58
+ const onRef = (ele) => {
59
+ bgController[key] = ele;
60
+ };
61
+ bgInfos.push({
62
+ url: value.url,
63
+ onRef,
64
+ onLoad: () => {
65
+ console.log("bg onLoad 2", value.onLoad);
66
+ value.onLoad?.();
67
+ },
68
+ });
69
+ }
70
+ return bgInfos;
71
+ };
72
+ const bgInfos = initBg(bgSourceMap);
73
+
74
+ onMounted(() => {
75
+ safeLoadJsvAudio();
76
+ });
77
+
78
+ onBeforeUnmount(() => {
79
+ sfxController = {};
80
+ soundPool?.destroy();
81
+
82
+ for (const [key, value] of Object.entries(bgController)) {
83
+ value?.pause();
84
+ value?.unload();
85
+ }
86
+ });
87
+
88
+ const playSfx = (sfxKey) => {
89
+ if (sfxController[sfxKey]) {
90
+ sfxController[sfxKey].play();
91
+ }
92
+ };
93
+
94
+ const playBg = (bgKey) => {
95
+ if (bgController[bgKey]) {
96
+ bgController[bgKey]?.play();
97
+ }
98
+ };
99
+
100
+ const pauseBg = (bgKey) => {
101
+ if (bgController[bgKey]) {
102
+ bgController[bgKey]?.pause();
103
+ }
104
+ };
105
+
106
+ return {
107
+ playSfx,
108
+ playBg,
109
+ pauseBg,
110
+ bgInfos,
111
+ };
112
+ }
@@ -1,6 +1,5 @@
1
1
  <template>
2
2
  <JsvSpriteLoader
3
- v-if="show"
4
3
  :imageUrl="spriteSrc"
5
4
  :configUrl="jsonUrl"
6
5
  :onConfigReady="preloadCallback"
@@ -15,35 +14,76 @@
15
14
  :spriteFrameSize="spriteOriginSize"
16
15
  :viewSize="{ w: layout.width, h: layout.height }"
17
16
  :onAnimEnd="onAnimEnd"
18
- :autostart="true"
17
+ :autostart="props.autoStart"
19
18
  />
20
19
  </JsvSpriteLoader>
21
20
  </template>
22
21
 
23
22
  <script setup>
24
- import { computed, shallowRef, onMounted } from "vue";
23
+ import { computed, shallowRef, onMounted, watch } from "vue";
25
24
  import { JsvSpriteAnim, JsvSpriteLoader, JsvSpriteTools } from "jsview";
26
25
 
27
26
  const props = defineProps({
27
+ /**
28
+ * 雪碧图资源URL
29
+ * @type {String}
30
+ */
28
31
  spriteSrc: {
29
32
  type: String,
30
33
  },
34
+ /**
35
+ * 动画循环次数
36
+ * -1表示无限循环
37
+ * @type {Number}
38
+ * @default 0
39
+ */
31
40
  repeat: {
32
41
  type: Number,
33
42
  },
43
+ /**
44
+ * 容器尺寸配置
45
+ * @type {Object}
46
+ * @property {number} width - 容器宽度
47
+ * @property {number} height - 容器高度
48
+ */
34
49
  layout: {
35
50
  type: Object,
36
51
  },
52
+ /**
53
+ * 动画结束回调函数
54
+ * @type {Function|undefined}
55
+ */
37
56
  onEnd: {
38
57
  type: Function,
39
58
  },
59
+ /**
60
+ * 动画持续时间(单位:ms)
61
+ * 当设置duration时会覆盖雪碧图原始帧间隔时间
62
+ * @type {Number}
63
+ */
40
64
  duration: {
41
65
  type: Number,
42
66
  },
67
+ /**
68
+ * 是否自动开始动画
69
+ * @type {Boolean}
70
+ * @default true
71
+ */
72
+ autoStart: {
73
+ type: Boolean,
74
+ default: true,
75
+ },
76
+ /**
77
+ * 动画结束帧
78
+ * @type {"start" | "end"}
79
+ */
80
+ endFrame: {
81
+ type: String,
82
+ default: "end",
83
+ },
43
84
  });
44
85
 
45
86
  const spriteController = shallowRef();
46
- const show = shallowRef(true);
47
87
 
48
88
  const jsonUrl = computed(() => {
49
89
  return props.spriteSrc + ".json";
@@ -70,8 +110,11 @@ const _formatInfo = (config_json) => {
70
110
  return { info };
71
111
  };
72
112
 
113
+ /**
114
+ * 动画结束处理函数
115
+ * 隐藏组件并触发外部回调
116
+ */
73
117
  function onAnimEnd() {
74
- show.value = false;
75
118
  props.onEnd?.();
76
119
  }
77
120
 
@@ -86,5 +129,19 @@ const preloadCallback = (config_json, resolve_set) => {
86
129
  resolve_set(); // 通知loader数组设置完成
87
130
  };
88
131
 
132
+ watch(spriteController, (value) => {
133
+ if (value) {
134
+ if (props.autoStart) {
135
+ value.start("all", props.endFrame, props.duration, props.repeat);
136
+ }
137
+ }
138
+ });
139
+
140
+ defineExpose({
141
+ play: () => {
142
+ spriteController.value.start("all", "end", props.duration, props.repeat);
143
+ },
144
+ });
145
+
89
146
  onMounted(() => {});
90
147
  </script>
@@ -15,40 +15,90 @@ import Item from "./Item.vue";
15
15
  import { ref, provide, onMounted } from "vue";
16
16
 
17
17
  const props = defineProps({
18
+ /**
19
+ * 组件名称标识
20
+ * @type {string}
21
+ */
18
22
  name: {
19
23
  type: String,
20
24
  required: true,
21
25
  },
22
- // { smallWidth: 0, largeWidth: 0, height: 0, marginRight: 10}
26
+ /**
27
+ * 元素尺寸配置对象
28
+ * @type {Object}
29
+ * @property {number} smallWidth - 小元素宽度
30
+ * @property {number} largeWidth - 大元素宽度
31
+ * @property {number} height - 元素高度
32
+ * @property {number} [marginRight=10] - 元素右侧间距
33
+ */
23
34
  itemSizeInfo: {
24
35
  type: Object,
25
36
  required: true,
26
37
  },
38
+ /**
39
+ * 数据源数组
40
+ * @type {Array<Object>}
41
+ */
27
42
  datas: {
28
43
  type: Array,
29
44
  required: true,
30
45
  },
46
+ /**
47
+ * 布局配置对象
48
+ * @type {Object}
49
+ * @property {number} width - 容器宽度
50
+ * @property {number} height - 容器高度
51
+ * @property {number} left - 左侧位置
52
+ * @property {number} top - 顶部位置
53
+ */
31
54
  layout: {
32
55
  type: Object,
33
56
  required: true,
34
57
  },
58
+ /**
59
+ * 初始大元素索引
60
+ * @type {number}
61
+ * @default 0
62
+ */
35
63
  initLargeIndex: {
36
64
  type: Number,
37
65
  default: 0,
38
66
  },
67
+ /**
68
+ * 获取焦点时的回调函数
69
+ * @type {Function}
70
+ */
39
71
  onFocus: {
40
72
  type: Function,
41
73
  },
74
+ /**
75
+ * 失去焦点时的回调函数
76
+ * @type {Function}
77
+ */
42
78
  onBlur: {
43
79
  type: Function,
44
80
  },
81
+ /**
82
+ * 到达边缘时的回调函数
83
+ * @type {Function}
84
+ * @param {Object} edgeInfo - 边缘信息对象
85
+ */
45
86
  onEdge: {
46
87
  type: Function,
47
88
  },
89
+ /**
90
+ * 元素点击事件回调
91
+ * @type {Function}
92
+ * @param {Object} itemData - 被点击元素的数据
93
+ */
48
94
  onItemClick: {
49
95
  type: Function,
50
96
  },
51
- //动画时长, 单位秒
97
+ /**
98
+ * 动画持续时间(单位:秒)
99
+ * @type {number}
100
+ * @default 0.2
101
+ */
52
102
  duration: {
53
103
  type: Number,
54
104
  default: 0.2,
@@ -0,0 +1,101 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-02-10 14:45:39
4
+ * @Description: file content
5
+ -->
6
+
7
+ <script setup>
8
+ import { JsvSwiper2, useFocusHub, EdgeDirection } from "jsview";
9
+ import { onMounted, ref } from "vue";
10
+ import Item from "./Item.vue";
11
+
12
+ const focusHub = useFocusHub();
13
+ const imgSrcList = [
14
+ "https://cdn.release.qcast.cn/JsViewFrameworkTester/JsViewVueSampleResources/Swiper/App/element_228543_img_20230610184253.png",
15
+ "https://cdn.release.qcast.cn/JsViewFrameworkTester/JsViewVueSampleResources/Swiper/App/element_228544_img_20230610184145.png",
16
+ "https://cdn.release.qcast.cn/JsViewFrameworkTester/JsViewVueSampleResources/Swiper/App/element_228545_img_20230610184110.png",
17
+ "https://cdn.release.qcast.cn/JsViewFrameworkTester/JsViewVueSampleResources/Swiper/App/element_228542_img_20230610184253.png",
18
+ ];
19
+ let itemSize = {
20
+ width: 400,
21
+ height: 600,
22
+ };
23
+ let data = [];
24
+ for (let i = 0; i < 10; i++) {
25
+ data.push({
26
+ width: itemSize.width,
27
+ height: itemSize.height,
28
+ index: i,
29
+ src: imgSrcList[i % imgSrcList.length],
30
+ });
31
+ }
32
+
33
+ const currentIndex = ref(0);
34
+ const swiper1 = {
35
+ onChange: (currentId) => {
36
+ currentIndex.value = currentId;
37
+ console.log("swiper1: onChange", currentId);
38
+ },
39
+ onClick: (currentId) => {
40
+ console.log("swiper1: onClick", currentId);
41
+ },
42
+ onEdge: (info) => {},
43
+ };
44
+
45
+ onMounted(() => {
46
+ focusHub.setFocus("mySwiper1");
47
+ });
48
+ const duration = 600;
49
+ </script>
50
+
51
+ <template>
52
+ <div
53
+ :style="{ width: 1280, height: 720, backgroundColor: '#000000cc' }"
54
+ ></div>
55
+ <div
56
+ :style="{
57
+ width: 1280,
58
+ height: 100,
59
+ fontSize: 30,
60
+ textAlign: 'center',
61
+ lineHeight: 100,
62
+ color: '#ffffff',
63
+ }"
64
+ >
65
+ 左右键切换轮播图显示海报
66
+ </div>
67
+ <div :style="{ left: (1280 - 700) / 2, top: 100 }">
68
+ <jsv-swiper2
69
+ name="mySwiper1"
70
+ ref="mySwiper1"
71
+ :totalFrame="data.length"
72
+ :layoutInfo="{
73
+ width: 700,
74
+ height: 600,
75
+ }"
76
+ :itemSize="itemSize"
77
+ :animation="{
78
+ duration: duration,
79
+ easing: 'jsv-ease(0.4, 0.8, 1.2)',
80
+ }"
81
+ :autoplayInterval="1000"
82
+ :onChange="swiper1.onChange"
83
+ :onClick="swiper1.onClick"
84
+ :onEdge="swiper1.onEdge"
85
+ :itemGap="10"
86
+ >
87
+ <template #itemView="{ dataIndex, focused, distanceToCenter }">
88
+ <item
89
+ :data="data[dataIndex]"
90
+ :index="dataIndex"
91
+ :currentIndex="currentIndex"
92
+ :focused="focused"
93
+ :borderRadius="40"
94
+ :collapseWidth="140"
95
+ :duration="duration"
96
+ :distanceToCenter="distanceToCenter"
97
+ />
98
+ </template>
99
+ </jsv-swiper2>
100
+ </div>
101
+ </template>
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <div
3
+ :style="{
4
+ width: data.width,
5
+ height: data.height,
6
+ backgroundColor: '#00ff00',
7
+ borderRadius: borderRadius,
8
+ }"
9
+ ></div>
10
+ <ParallaxSlide
11
+ ref="pandaAnim"
12
+ :imgUrl="data.src"
13
+ :width="data.width"
14
+ :height="data.height"
15
+ :collapseWidth="collapseWidth"
16
+ :duration="duration"
17
+ :borderRadius="borderRadius"
18
+ :initPosition="initPosition"
19
+ easing="jsv-ease(0.4, 0.8, 1.2)"
20
+ ></ParallaxSlide>
21
+ </template>
22
+ <script setup>
23
+ import ParallaxSlide from "./ParallaxSlide.vue";
24
+ import { shallowRef, watch } from "vue";
25
+ const props = defineProps({
26
+ data: Object,
27
+ focused: Boolean,
28
+ duration: Number,
29
+ borderRadius: Number,
30
+ collapseWidth: Number,
31
+ currentIndex: Number,
32
+ index: Number,
33
+ distanceToCenter: Number,
34
+ });
35
+ const initPosition =
36
+ props.distanceToCenter === 0
37
+ ? "center"
38
+ : props.distanceToCenter > 0
39
+ ? "right"
40
+ : "left";
41
+
42
+ const pandaAnim = shallowRef(null);
43
+
44
+ watch(
45
+ () => props.distanceToCenter,
46
+ (newVal) => {
47
+ if (newVal === 0) {
48
+ pandaAnim.value.slide("center");
49
+ } else if (newVal == 1) {
50
+ pandaAnim.value.slide("right");
51
+ } else if (newVal == -1) {
52
+ pandaAnim.value.slide("left");
53
+ }
54
+ }
55
+ );
56
+ </script>