@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.
- package/DashPath/App.vue +17 -16
- package/DashPath/AppForOperator.vue +2 -4
- package/DemoForOperator/AnimPic/AnimPic.vue +24 -2
- package/DemoForOperator/Banger/Banger/Banger.vue +73 -9
- package/DemoForOperator/Blur/Blur.vue +146 -0
- package/DemoForOperator/Blur/BlurInOut/BlurInOut.vue +158 -0
- package/DemoForOperator/Blur/BlurInOut/StaticBgSlide.vue +162 -0
- package/DemoForOperator/Blur/BlurPopup/BlurPopup.vue +113 -0
- package/DemoForOperator/BookFlip/App.vue +115 -0
- package/DemoForOperator/BookFlip/BookFlip/FlipPage.vue +179 -0
- package/DemoForOperator/BookFlip/BookFlip/FlippingBook.vue +310 -0
- package/DemoForOperator/BookFlip/BookFlip/flip.glsl +135 -0
- package/DemoForOperator/BookFlip/BookPage.vue +82 -0
- package/DemoForOperator/Bounce/Bounce.vue +33 -1
- package/DemoForOperator/ChunLian/Couplets.vue +44 -1
- package/DemoForOperator/ClickSpriteAnim/App.vue +130 -0
- package/DemoForOperator/ClickSpriteAnim/Item.vue +74 -0
- package/DemoForOperator/DominantColor/App.vue +187 -0
- package/DemoForOperator/EpisodeList/EpisodeList/Controller.vue +0 -3
- package/DemoForOperator/EpisodeList/EpisodeList/EpisodeList.vue +76 -2
- package/DemoForOperator/Firework1/App.vue +1 -1
- package/DemoForOperator/Firework1/Fireworks.vue +50 -11
- package/DemoForOperator/FlipPage/FlipPage/FlipPage.vue +29 -1
- package/DemoForOperator/Focus/Alpha/AlphaFocusBox.vue +27 -2
- package/DemoForOperator/Focus/Light/LightFocusBox.vue +42 -1
- package/DemoForOperator/Focus/Normal/NormalFocusBox.vue +12 -0
- package/DemoForOperator/FrameShadow/App.vue +193 -0
- package/DemoForOperator/FrameShadow/FrameShadow.vue +61 -0
- package/DemoForOperator/FullscreenIn/App.vue +1 -1
- package/DemoForOperator/FullscreenIn/FullscreenPoster.vue +18 -3
- package/DemoForOperator/Genie/geniePakcer/Genie.vue +60 -18
- package/DemoForOperator/GrayFilter/GrayFilter.vue +21 -0
- package/DemoForOperator/Jigsaw/JigsawFull.vue +46 -4
- package/DemoForOperator/Jigsaw/JigsawSingle.vue +34 -2
- package/DemoForOperator/LongChatBox/App.vue +36 -0
- package/DemoForOperator/LongChatBox/Bubble.vue +104 -0
- package/DemoForOperator/LongChatBox/LongChat.vue +173 -0
- package/DemoForOperator/LongChatBox/TextManager.ts +147 -0
- package/DemoForOperator/LongChatBox/VirtualList.vue +298 -0
- package/DemoForOperator/LongChatBox/testData.js +51 -0
- package/DemoForOperator/LongChatBox/utile.js +331 -0
- package/DemoForOperator/Particle/Drop/DropParticle.vue +33 -1
- package/DemoForOperator/Particle/Explode/ExplodeParticle.vue +23 -2
- package/DemoForOperator/PosterAnim/PosterAnim.js +21 -0
- package/DemoForOperator/PosterOverflow/PosterOverflow.vue +16 -0
- package/DemoForOperator/Resize/App.vue +157 -0
- package/DemoForOperator/Resize/Resize/Item.vue +234 -0
- package/DemoForOperator/Resize/Resize/Resize.vue +96 -0
- package/DemoForOperator/Ripple/Ripple.vue +16 -1
- package/DemoForOperator/ScreenShootScale/App.vue +96 -0
- package/DemoForOperator/ScreenShootScale/Back.vue +86 -0
- package/DemoForOperator/ScreenShootScale/Front.vue +133 -0
- package/DemoForOperator/ScreenShootScale/Item.vue +62 -0
- package/DemoForOperator/ScreenShootScale/ScreenShootScale.vue +109 -0
- package/DemoForOperator/SmoothSwiper/App.vue +50 -0
- package/DemoForOperator/Sound/Bounce/App.vue +56 -0
- package/DemoForOperator/Sound/Bounce/Bounce.vue +87 -0
- package/DemoForOperator/Sound/Bounce/FreeMoveBuilder.js +146 -0
- package/DemoForOperator/Sound/Bounce/bgmusic.mp3 +0 -0
- package/DemoForOperator/Sound/Bounce/coin.mp3 +0 -0
- package/DemoForOperator/Sound/FocusMove/App.vue +134 -0
- package/DemoForOperator/Sound/FocusMove/Item.vue +43 -0
- package/DemoForOperator/Sound/FocusMove/move.mp3 +0 -0
- package/DemoForOperator/Sound/Rain/App.vue +11 -0
- package/DemoForOperator/Sound/Rain/Raining/Rain.vue +69 -0
- package/DemoForOperator/Sound/Rain/Raining/RainScene.vue +118 -0
- package/DemoForOperator/Sound/Sound/Sound.vue +24 -0
- package/DemoForOperator/Sound/Sound/index.js +4 -0
- package/DemoForOperator/Sound/Sound/useSound.js +112 -0
- package/DemoForOperator/Sprite/Sprite.vue +62 -5
- package/DemoForOperator/Stretch/Stretch/Stretch.vue +52 -2
- package/DemoForOperator/Swiper/App.vue +101 -0
- package/DemoForOperator/Swiper/Item.vue +56 -0
- package/DemoForOperator/Swiper/ParallaxSlide.vue +164 -0
- package/DemoForOperator/TabContent/TabContent/TabContent.vue +39 -1
- package/DemoForOperator/TabContentVertical/App.vue +104 -0
- package/DemoForOperator/TabContentVertical/ContentPage.vue +67 -0
- package/DemoForOperator/TabContentVertical/Item.vue +94 -0
- package/DemoForOperator/TabContentVertical/PageItem.vue +40 -0
- package/DemoForOperator/TabContentVertical/TabContent/CreepFocus.vue +160 -0
- package/DemoForOperator/TabContentVertical/TabContent/Item.vue +63 -0
- package/DemoForOperator/TabContentVertical/TabContent/TabContent.vue +184 -0
- package/DemoForOperator/TabContentVertical/TabContent/TabItem.vue +368 -0
- package/DemoForOperator/TabContentVertical/TabContent/TabWidget.vue +259 -0
- package/DemoForOperator/TabContentVertical/TabContent/Util.js +3 -0
- package/DemoForOperator/TabContentVertical/TabContent/ViewSwiper.vue +110 -0
- package/DemoForOperator/TabContentVertical/assets/children_science.png +0 -0
- package/DemoForOperator/TabContentVertical/assets/documentary.png +0 -0
- package/DemoForOperator/TabContentVertical/assets/free.png +0 -0
- package/DemoForOperator/TabContentVertical/assets/game.png +0 -0
- package/DemoForOperator/TabContentVertical/assets/home_selected.png +0 -0
- package/DemoForOperator/TabContentVertical/assets/movie_ticket.png +0 -0
- package/DemoForOperator/TabContentVertical/assets/my_account.png +0 -0
- package/DemoForOperator/TabContentVertical/assets/opera.png +0 -0
- package/DemoForOperator/TabContentVertical/assets/sports.png +0 -0
- package/DemoForOperator/TabContentVertical/assets/tv_drama.png +0 -0
- package/DemoForOperator/TabContentVertical/assets/variety_show.png +0 -0
- package/DemoForOperator/TabContentVertical/assets/vip.png +0 -0
- package/DemoForOperator/TabContentVertical/testData.js +76 -0
- package/DemoForOperator/Vortex/Vortex/Vortex.vue +26 -0
- package/DemoForOperator/routeList.js +118 -1
- package/DemoHomepage/components/Item.vue +11 -0
- package/DemoHomepage/router.js +75 -1
- package/GiftRain/components/SpriteTranslate.vue +68 -48
- package/HashHistory/App.vue +2 -2
- package/HashHistory/router.js +1 -1
- package/MetroWidgetDemos/TripleWidget/App.vue +7 -1
- package/MetroWidgetDemos/TripleWidget/Item.vue +16 -2
- package/MetroWidgetDemos/TripleWidget/SWidgetItem.vue +7 -1
- package/MetroWidgetDemos/TripleWidget/WidgetItem.vue +8 -2
- package/MetroWidgetDemos/routeList.js +17 -0
- package/PosterPacker/App.vue +2 -2
- package/ViewOpacity/App.vue +19 -0
- package/package.json +1 -1
- package/DashPath/DashPath.vue +0 -118
- package/DemoForOperator/ScalePoster/App.vue +0 -4
- package/DemoForOperator/ScalePoster/ScalePoster.vue +0 -0
package/DashPath/App.vue
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
}"
|
|
8
8
|
>
|
|
9
9
|
<!-- 带缺口的矩形 -->
|
|
10
|
-
<
|
|
10
|
+
<JsvDashPath
|
|
11
11
|
:points="[
|
|
12
12
|
{ x: 200, y: 0 }, // 右上角
|
|
13
13
|
{ x: 200, y: 100 }, // 右边中点(缺口处)
|
|
@@ -23,17 +23,15 @@
|
|
|
23
23
|
:layout="{
|
|
24
24
|
left: 50,
|
|
25
25
|
top: 50,
|
|
26
|
-
width: 250,
|
|
27
|
-
height: 200,
|
|
28
26
|
}"
|
|
29
27
|
/>
|
|
30
28
|
|
|
31
29
|
<!-- 三角形 -->
|
|
32
|
-
<
|
|
30
|
+
<JsvDashPath
|
|
33
31
|
:points="[
|
|
34
|
-
{ x:
|
|
35
|
-
{ x:
|
|
36
|
-
{ x:
|
|
32
|
+
{ x: -50, y: -50 }, // 顶点
|
|
33
|
+
{ x: 50, y: -50 }, // 右下角
|
|
34
|
+
{ x: 50, y: 150 }, // 左下角
|
|
37
35
|
]"
|
|
38
36
|
:dash="[15, 8]"
|
|
39
37
|
:phase="2"
|
|
@@ -41,14 +39,19 @@
|
|
|
41
39
|
:lineWidth="4"
|
|
42
40
|
:layout="{
|
|
43
41
|
left: 350,
|
|
44
|
-
top:
|
|
45
|
-
width: 250,
|
|
46
|
-
height: 200,
|
|
42
|
+
top: 100,
|
|
47
43
|
}"
|
|
48
44
|
/>
|
|
45
|
+
<div :style="{
|
|
46
|
+
left: 350,
|
|
47
|
+
top: 100,
|
|
48
|
+
width: 5,
|
|
49
|
+
height: 5,
|
|
50
|
+
backgroundColor: '#00FF00',
|
|
51
|
+
}"></div>
|
|
49
52
|
|
|
50
53
|
<!-- 凸字形 -->
|
|
51
|
-
<
|
|
54
|
+
<JsvDashPath
|
|
52
55
|
:points="[
|
|
53
56
|
{ x: 0, y: 0 }, // 左上角
|
|
54
57
|
{ x: 200, y: 0 }, // 右上角
|
|
@@ -62,18 +65,16 @@
|
|
|
62
65
|
:dash="[20, 10]"
|
|
63
66
|
:phase="5"
|
|
64
67
|
color="#0088FF"
|
|
65
|
-
:lineWidth="
|
|
68
|
+
:lineWidth="10"
|
|
66
69
|
:layout="{
|
|
67
70
|
left: 650,
|
|
68
71
|
top: 50,
|
|
69
|
-
width: 250,
|
|
70
|
-
height: 200,
|
|
71
72
|
}"
|
|
72
73
|
/>
|
|
73
74
|
</div>
|
|
74
75
|
</template>
|
|
75
76
|
|
|
76
77
|
<script setup>
|
|
77
|
-
import
|
|
78
|
-
|
|
78
|
+
import { JsvDashPath } from "jsview";
|
|
79
|
+
</script>
|
|
79
80
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
}"
|
|
8
8
|
>
|
|
9
9
|
<!-- 带缺口的矩形 -->
|
|
10
|
-
<
|
|
10
|
+
<JsvDashPath
|
|
11
11
|
:points="[
|
|
12
12
|
{ x: 200, y: 0 }, // 右上角
|
|
13
13
|
{ x: 200, y: 100 }, // 右边中点(缺口处)
|
|
@@ -22,14 +22,12 @@
|
|
|
22
22
|
:layout="{
|
|
23
23
|
left: 150,
|
|
24
24
|
top: 150,
|
|
25
|
-
width: 250,
|
|
26
|
-
height: 200,
|
|
27
25
|
}"
|
|
28
26
|
/>
|
|
29
27
|
</div>
|
|
30
28
|
</template>
|
|
31
29
|
|
|
32
30
|
<script setup>
|
|
33
|
-
import
|
|
31
|
+
import { JsvDashPath } from "jsview";
|
|
34
32
|
</script>
|
|
35
33
|
|
|
@@ -5,18 +5,40 @@
|
|
|
5
5
|
<script setup>
|
|
6
6
|
import { JsvApic2, LoopType, ApicEndState } from "jsview";
|
|
7
7
|
import { shallowRef, onMounted } from "vue";
|
|
8
|
+
|
|
8
9
|
const props = defineProps({
|
|
10
|
+
/**
|
|
11
|
+
* 动画资源路径(必填)
|
|
12
|
+
* @type {String}
|
|
13
|
+
* @required
|
|
14
|
+
*/
|
|
9
15
|
src: {
|
|
10
16
|
type: String,
|
|
11
17
|
required: true,
|
|
12
18
|
},
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 动画循环配置
|
|
22
|
+
* @type {Number|String}
|
|
23
|
+
* @default 0
|
|
24
|
+
* @property {Number} [>=0] - 有限循环次数(0表示不循环)
|
|
25
|
+
* @property {Number} [-1] - 无限循环
|
|
26
|
+
* @property {String} ['default'] - 使用动画默认循环设置
|
|
27
|
+
* @property {String} ['infinite'] - 无限循环
|
|
28
|
+
*/
|
|
13
29
|
repeat: {
|
|
14
30
|
type: [String, Number],
|
|
15
|
-
default: 0,
|
|
31
|
+
default: 0, // 默认不循环
|
|
16
32
|
},
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 布局样式配置
|
|
36
|
+
* @type {Object}
|
|
37
|
+
* @optional
|
|
38
|
+
*/
|
|
17
39
|
layout: {
|
|
18
40
|
type: Object,
|
|
19
|
-
}
|
|
41
|
+
}
|
|
20
42
|
});
|
|
21
43
|
|
|
22
44
|
const apicRef = shallowRef();
|
|
@@ -109,15 +109,79 @@ import {
|
|
|
109
109
|
import { _formatInfo } from "./SpriteDeal";
|
|
110
110
|
|
|
111
111
|
const props = defineProps({
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
/**
|
|
113
|
+
* 组件顶端中心Left位置(单位:px)
|
|
114
|
+
* @type {Number}
|
|
115
|
+
* @default 0
|
|
116
|
+
*/
|
|
117
|
+
left: {
|
|
118
|
+
type: Number,
|
|
119
|
+
default: 0
|
|
120
|
+
},
|
|
121
|
+
/**
|
|
122
|
+
* 组件顶端中心Top位置(单位:px)
|
|
123
|
+
* @type {Number}
|
|
124
|
+
* @default 0
|
|
125
|
+
*/
|
|
126
|
+
top: {
|
|
127
|
+
type: Number,
|
|
128
|
+
default: 0
|
|
129
|
+
},
|
|
130
|
+
/**
|
|
131
|
+
* 鞭炮个数(决定组件长度)
|
|
132
|
+
* @type {Number}
|
|
133
|
+
* @default 12
|
|
134
|
+
*/
|
|
135
|
+
num: {
|
|
136
|
+
type: Number,
|
|
137
|
+
default: 12
|
|
138
|
+
},
|
|
139
|
+
/**
|
|
140
|
+
* 组件整体宽度(单位:px)
|
|
141
|
+
* @type {Number}
|
|
142
|
+
* @requires true
|
|
143
|
+
*/
|
|
144
|
+
width: {
|
|
145
|
+
type: Number,
|
|
146
|
+
require: true
|
|
147
|
+
},
|
|
148
|
+
/**
|
|
149
|
+
* 引线燃烧时间(单位:秒)
|
|
150
|
+
* @type {Number}
|
|
151
|
+
* @requires true
|
|
152
|
+
*/
|
|
153
|
+
leadWireTime: {
|
|
154
|
+
type: Number,
|
|
155
|
+
require: true
|
|
156
|
+
},
|
|
157
|
+
/**
|
|
158
|
+
* 星星特效资源路径数组
|
|
159
|
+
* @type {Array}
|
|
160
|
+
*/
|
|
161
|
+
starSrcs: {
|
|
162
|
+
type: Array
|
|
163
|
+
},
|
|
164
|
+
/**
|
|
165
|
+
* 鞭炮资源路径
|
|
166
|
+
* @type {String}
|
|
167
|
+
*/
|
|
168
|
+
bangerSpriteSrc: {
|
|
169
|
+
type: String
|
|
170
|
+
},
|
|
171
|
+
/**
|
|
172
|
+
* 火花特效动画资源路径
|
|
173
|
+
* @type {String}
|
|
174
|
+
*/
|
|
175
|
+
sparkSpriteSrc: {
|
|
176
|
+
type: String
|
|
177
|
+
},
|
|
178
|
+
/**
|
|
179
|
+
* 引线图片资源路径
|
|
180
|
+
* @type {String}
|
|
181
|
+
*/
|
|
182
|
+
leadWireSrc: {
|
|
183
|
+
type: String
|
|
184
|
+
}
|
|
121
185
|
});
|
|
122
186
|
|
|
123
187
|
const leadWire = props.leadWireSrc;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @file Blur.vue
|
|
3
|
+
*
|
|
4
|
+
* 【模块 export 内容】
|
|
5
|
+
* Blur:Vue组件,用于显示模糊效果的纹理
|
|
6
|
+
* layout {Object}: (必填)组件布局信息对象,包含组件的位置和尺寸
|
|
7
|
+
* 格式为 {left: number, top: number, width: number, height: number}
|
|
8
|
+
* showRectPos {Object}: (必填)显示内容相对于原图左上角的位置
|
|
9
|
+
* 格式为 {left: number, top: number}
|
|
10
|
+
* borderRadius {Number}: 边框圆角半径,默认值 0
|
|
11
|
+
* textureInfo {Object}: (必填)纹理信息对象,一般是captureBlurTexture的返回值
|
|
12
|
+
* 格式为 {textureId: string, width: number, height: number}
|
|
13
|
+
*
|
|
14
|
+
* captureBlurTexture(divRef, blurRadius): 捕获模糊纹理的方法
|
|
15
|
+
* divRef {HTMLElement}: 要捕获的DOM元素引用
|
|
16
|
+
* blurRadius {Number}: 模糊半径
|
|
17
|
+
* 返回值 {Promise<Object>}: 包含纹理信息的Promise,格式为 {textureId: string, width: number, height: number}
|
|
18
|
+
*
|
|
19
|
+
* 注意事项:
|
|
20
|
+
* 组件会根据传入的textureInfo自动计算变换和缩放
|
|
21
|
+
* 使用前需要先调用captureBlurTexture方法获取纹理信息
|
|
22
|
+
-->
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<jsv-texture-anim
|
|
26
|
+
:key="randomKey"
|
|
27
|
+
:src="sourceSrc"
|
|
28
|
+
:left="layout.left"
|
|
29
|
+
:top="layout.top"
|
|
30
|
+
:width="layout.width"
|
|
31
|
+
:height="layout.height"
|
|
32
|
+
:transform="translateTransform"
|
|
33
|
+
:borderRadius="borderRadius"
|
|
34
|
+
></jsv-texture-anim>
|
|
35
|
+
</template>
|
|
36
|
+
<script setup>
|
|
37
|
+
import { JsvTextureAnim } from "jsview";
|
|
38
|
+
import { shallowRef, computed } from "vue";
|
|
39
|
+
|
|
40
|
+
const randomKey = Math.random().toString(36).substring(2, 15);
|
|
41
|
+
|
|
42
|
+
const props = defineProps({
|
|
43
|
+
/**
|
|
44
|
+
* @description 布局信息对象,包含组件的位置和尺寸
|
|
45
|
+
* @property {number} left - 组件左侧位置
|
|
46
|
+
* @property {number} top - 组件顶部位置
|
|
47
|
+
* @property {number} width - 组件宽度
|
|
48
|
+
* @property {number} height - 组件高度
|
|
49
|
+
*/
|
|
50
|
+
layout: {
|
|
51
|
+
type: Object,
|
|
52
|
+
required: true,
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* @description 显示内容相对于原图左上角的位置
|
|
56
|
+
* @property {number} left - 显示区域左侧位置
|
|
57
|
+
* @property {number} top - 显示区域顶部位置
|
|
58
|
+
*/
|
|
59
|
+
showRectPos: {
|
|
60
|
+
type: Object,
|
|
61
|
+
required: true,
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* @description 边框圆角半径
|
|
65
|
+
* @default 0
|
|
66
|
+
*/
|
|
67
|
+
borderRadius: {
|
|
68
|
+
type: Number,
|
|
69
|
+
default: 0,
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
* @description 纹理信息对象, 一般是captureBlurTexture的返回值
|
|
73
|
+
* @property {string} textureId - 纹理ID
|
|
74
|
+
* @property {number} width - 纹理宽度
|
|
75
|
+
* @property {number} height - 纹理高度
|
|
76
|
+
*/
|
|
77
|
+
textureInfo: {
|
|
78
|
+
type: Object,
|
|
79
|
+
required: true,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
const sourceSrc = computed(() => {
|
|
83
|
+
console.log("sourceSrc", props.textureInfo?.textureId);
|
|
84
|
+
return props.textureInfo?.textureId
|
|
85
|
+
? `jsvtexturestore://${props.textureInfo.textureId}`
|
|
86
|
+
: "";
|
|
87
|
+
});
|
|
88
|
+
const translateTransform = computed(() => {
|
|
89
|
+
const leftPercent =
|
|
90
|
+
((-props.showRectPos.left -
|
|
91
|
+
(props.layout.width - props.textureInfo.width) / 2) /
|
|
92
|
+
props.layout.width) *
|
|
93
|
+
100;
|
|
94
|
+
const topPercent =
|
|
95
|
+
((-props.showRectPos.top -
|
|
96
|
+
(props.layout.height - props.textureInfo.height) / 2) /
|
|
97
|
+
props.layout.height) *
|
|
98
|
+
100;
|
|
99
|
+
const xScale = props.textureInfo.width / props.layout.width;
|
|
100
|
+
const yScale = props.textureInfo.height / props.layout.height;
|
|
101
|
+
const r = `translate3d(${leftPercent.toFixed(2)}%, ${topPercent.toFixed(2)}%, 0) scale3d(${xScale.toFixed(2)}, ${yScale.toFixed(2)}, 1)`;
|
|
102
|
+
console.log("ccht translateTransform", r);
|
|
103
|
+
return r;
|
|
104
|
+
});
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<script>
|
|
108
|
+
import { JsvTextureStoreApi, CaptureProcessType } from "jsview";
|
|
109
|
+
/**
|
|
110
|
+
* @description 捕获模糊纹理
|
|
111
|
+
* @param {HTMLElement} divRef - 要捕获的DOM元素引用
|
|
112
|
+
* @param {number} blurRadius - 模糊半径
|
|
113
|
+
* @returns {Promise<Object>} 返回包含纹理信息的Promise
|
|
114
|
+
* @property {string} textureId - 捕获的纹理ID
|
|
115
|
+
* @property {number} width - 纹理宽度
|
|
116
|
+
* @property {number} height - 纹理高度
|
|
117
|
+
*/
|
|
118
|
+
export function captureBlurTexture(divRef, blurRadius) {
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
try {
|
|
121
|
+
JsvTextureStoreApi.capture2Texture(
|
|
122
|
+
divRef,
|
|
123
|
+
(textureName, autoRecycle, w, h) => {
|
|
124
|
+
console.log("ccht captureBlurTexture", textureName, autoRecycle, w, h);
|
|
125
|
+
if (textureName) {
|
|
126
|
+
resolve({
|
|
127
|
+
textureId: textureName,
|
|
128
|
+
width: w,
|
|
129
|
+
height: h,
|
|
130
|
+
});
|
|
131
|
+
} else {
|
|
132
|
+
reject(new Error("Failed to capture texture"));
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
true,
|
|
136
|
+
{
|
|
137
|
+
type: CaptureProcessType.Blur,
|
|
138
|
+
radius: blurRadius,
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
} catch (error) {
|
|
142
|
+
reject(error);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
</script>
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { shallowRef, onMounted } from "vue";
|
|
3
|
+
import Blur, { captureBlurTexture } from "../Blur.vue";
|
|
4
|
+
import StaticBgSlide from "./StaticBgSlide.vue";
|
|
5
|
+
|
|
6
|
+
const vToCapture = shallowRef(null);
|
|
7
|
+
const vTextureInfo = shallowRef(null);
|
|
8
|
+
|
|
9
|
+
let isBlur = false;
|
|
10
|
+
function enableBlur() {
|
|
11
|
+
if (isBlur) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
isBlur = true;
|
|
15
|
+
captureBlurTexture(vToCapture.value, 12).then((textureInfo) => {
|
|
16
|
+
vTextureInfo.value = textureInfo;
|
|
17
|
+
setTimeout(() => {
|
|
18
|
+
curPosition.left = 0;
|
|
19
|
+
bgAnim.value?.slide(curPosition);
|
|
20
|
+
}, 0);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const ImagePanda =
|
|
25
|
+
"https://cdn.release.qcast.cn/JsViewFrameworkTester/JsViewVueSampleResources/CustomShader/App/panda.jpeg";
|
|
26
|
+
|
|
27
|
+
let curPosition = {
|
|
28
|
+
left: 0,
|
|
29
|
+
top: 0,
|
|
30
|
+
};
|
|
31
|
+
let width1 = 300;
|
|
32
|
+
let height1 = 720;
|
|
33
|
+
const bgAnim = shallowRef(null);
|
|
34
|
+
const onKeyDown = (ev) => {
|
|
35
|
+
console.log("ccht", ev.keyCode);
|
|
36
|
+
switch (ev.keyCode) {
|
|
37
|
+
case 37:
|
|
38
|
+
if (isBlur) {
|
|
39
|
+
curPosition.left = -width1;
|
|
40
|
+
bgAnim.value?.slide(curPosition);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
break;
|
|
44
|
+
case 39:
|
|
45
|
+
if (isBlur) {
|
|
46
|
+
curPosition.left = 0;
|
|
47
|
+
bgAnim.value?.slide(curPosition);
|
|
48
|
+
} else {
|
|
49
|
+
enableBlur();
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
// case 38:
|
|
53
|
+
// curPosition.top = curPosition.top - 100;
|
|
54
|
+
// bgAnim.value?.slide(curPosition);
|
|
55
|
+
// break;
|
|
56
|
+
// case 40:
|
|
57
|
+
// curPosition.top = curPosition.top + 100;
|
|
58
|
+
// bgAnim.value?.slide(curPosition);
|
|
59
|
+
// break;
|
|
60
|
+
// case 13:
|
|
61
|
+
// enableBlur();
|
|
62
|
+
// break;
|
|
63
|
+
default:
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
onMounted(() => {
|
|
69
|
+
// enableBlur();
|
|
70
|
+
});
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<template>
|
|
74
|
+
<jsv-focus-block
|
|
75
|
+
autoFocus
|
|
76
|
+
:onAction="{
|
|
77
|
+
onKeyDown: onKeyDown,
|
|
78
|
+
}"
|
|
79
|
+
>
|
|
80
|
+
<div
|
|
81
|
+
ref="vToCapture"
|
|
82
|
+
:style="{
|
|
83
|
+
width: 1280, // 截屏区域的宽
|
|
84
|
+
height: 720, // 截屏区域的高
|
|
85
|
+
}"
|
|
86
|
+
>
|
|
87
|
+
<div
|
|
88
|
+
:style="{
|
|
89
|
+
width: 1280,
|
|
90
|
+
height: 720,
|
|
91
|
+
backgroundImage: `url(${ImagePanda})`,
|
|
92
|
+
}"
|
|
93
|
+
/>
|
|
94
|
+
<div
|
|
95
|
+
:style="{
|
|
96
|
+
top: 300,
|
|
97
|
+
width: 1280,
|
|
98
|
+
// height: 81,
|
|
99
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
100
|
+
color: '#ffffff',
|
|
101
|
+
// fontSize: 68,
|
|
102
|
+
textAlign: 'center',
|
|
103
|
+
// lineHeight: 81,
|
|
104
|
+
|
|
105
|
+
height: 38,
|
|
106
|
+
lineHeight: 38,
|
|
107
|
+
fontSize: 36,
|
|
108
|
+
fontWeight: 'bold',
|
|
109
|
+
}"
|
|
110
|
+
>
|
|
111
|
+
左右键展开/隐藏面板
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<div v-if="vTextureInfo">
|
|
116
|
+
<StaticBgSlide
|
|
117
|
+
key="bg"
|
|
118
|
+
ref="bgAnim"
|
|
119
|
+
:imgUrl="`jsvtexturestore://${vTextureInfo.textureId}`"
|
|
120
|
+
:width="width1"
|
|
121
|
+
:height="height1"
|
|
122
|
+
:bgWidth="1280"
|
|
123
|
+
:bgHeight="720"
|
|
124
|
+
:borderRadius="'0 30 30 0'"
|
|
125
|
+
:initPosition="{
|
|
126
|
+
left: -width1,
|
|
127
|
+
top: 0,
|
|
128
|
+
}"
|
|
129
|
+
>
|
|
130
|
+
<div
|
|
131
|
+
:style="{
|
|
132
|
+
width: width1,
|
|
133
|
+
height: height1,
|
|
134
|
+
backgroundColor: 'rgba(0, 0, 0, 0.3)',
|
|
135
|
+
borderRadius: '0 30 30 0',
|
|
136
|
+
lineHeight: height1,
|
|
137
|
+
textAlign: 'center',
|
|
138
|
+
color: '#ffffff',
|
|
139
|
+
fontSize: 40,
|
|
140
|
+
}"
|
|
141
|
+
>
|
|
142
|
+
弹窗内容
|
|
143
|
+
</div>
|
|
144
|
+
</StaticBgSlide>
|
|
145
|
+
</div>
|
|
146
|
+
</jsv-focus-block>
|
|
147
|
+
</template>
|
|
148
|
+
|
|
149
|
+
<style>
|
|
150
|
+
@keyframes rotate {
|
|
151
|
+
0% {
|
|
152
|
+
transform: rotate3d(0, 0, 1, 0deg);
|
|
153
|
+
}
|
|
154
|
+
100% {
|
|
155
|
+
transform: rotate3d(0, 0, 1, 360deg);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
</style>
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<jsv-preload
|
|
3
|
+
v-if="needPreload"
|
|
4
|
+
key="preload"
|
|
5
|
+
:preloadList="[preloadInfo]"
|
|
6
|
+
:onPreloadDone="handlePreloadDone"
|
|
7
|
+
></jsv-preload>
|
|
8
|
+
<div
|
|
9
|
+
:style="{
|
|
10
|
+
width: props.width,
|
|
11
|
+
height: props.height,
|
|
12
|
+
left: curPosition.left,
|
|
13
|
+
top: curPosition.top,
|
|
14
|
+
transition: `left ${props.duration}ms, top ${props.duration}ms`,
|
|
15
|
+
}"
|
|
16
|
+
>
|
|
17
|
+
<jsv-texture-anim
|
|
18
|
+
v-if="isPreloadDone"
|
|
19
|
+
ref="pandaAnim"
|
|
20
|
+
:src="props.imgUrl"
|
|
21
|
+
:width="props.width"
|
|
22
|
+
:height="props.height"
|
|
23
|
+
:animation="appliedAnim"
|
|
24
|
+
:duration="props.duration"
|
|
25
|
+
:transform="appliedTrans"
|
|
26
|
+
:borderRadius="props.borderRadius"
|
|
27
|
+
:autoStart="false"
|
|
28
|
+
:onAnimationEnd="onAnimEnd"
|
|
29
|
+
></jsv-texture-anim>
|
|
30
|
+
<slot></slot>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script setup>
|
|
35
|
+
import { ref, shallowRef, computed, reactive } from "vue";
|
|
36
|
+
import { JsvPreload, buildPreloadInfo } from "jsview";
|
|
37
|
+
import { JsvTextureAnim } from "jsview";
|
|
38
|
+
|
|
39
|
+
const props = defineProps({
|
|
40
|
+
imgUrl: {
|
|
41
|
+
type: String,
|
|
42
|
+
required: true,
|
|
43
|
+
},
|
|
44
|
+
width: {
|
|
45
|
+
type: Number,
|
|
46
|
+
required: true,
|
|
47
|
+
},
|
|
48
|
+
height: {
|
|
49
|
+
type: Number,
|
|
50
|
+
required: true,
|
|
51
|
+
},
|
|
52
|
+
bgWidth: {
|
|
53
|
+
type: Number,
|
|
54
|
+
required: true,
|
|
55
|
+
},
|
|
56
|
+
bgHeight: {
|
|
57
|
+
type: Number,
|
|
58
|
+
required: true,
|
|
59
|
+
},
|
|
60
|
+
duration: {
|
|
61
|
+
type: Number,
|
|
62
|
+
default: 200,
|
|
63
|
+
},
|
|
64
|
+
easing: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: "linear",
|
|
67
|
+
},
|
|
68
|
+
borderRadius: {
|
|
69
|
+
type: Number,
|
|
70
|
+
default: 0,
|
|
71
|
+
},
|
|
72
|
+
initPosition: {
|
|
73
|
+
type: Object,
|
|
74
|
+
default: () => ({
|
|
75
|
+
left: 0,
|
|
76
|
+
top: 0,
|
|
77
|
+
}),
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const needPreload = ref(false);
|
|
82
|
+
const isPreloadDone = ref(false);
|
|
83
|
+
let preloadInfo = [];
|
|
84
|
+
if (props.imgUrl.includes("jsvtexturestore://")) {
|
|
85
|
+
needPreload.value = false;
|
|
86
|
+
isPreloadDone.value = true;
|
|
87
|
+
} else {
|
|
88
|
+
needPreload.value = true;
|
|
89
|
+
isPreloadDone.value = false;
|
|
90
|
+
preloadInfo = buildPreloadInfo(props.imgUrl);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const pandaAnim = shallowRef(null);
|
|
94
|
+
//view相对于bg的偏移量
|
|
95
|
+
const curPosition = reactive(props.initPosition);
|
|
96
|
+
|
|
97
|
+
const baseScale = computed(
|
|
98
|
+
() =>
|
|
99
|
+
`scale3d(${props.bgWidth / props.width}, ${
|
|
100
|
+
props.bgHeight / props.height
|
|
101
|
+
}, 1)`
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const scaleOffset = {
|
|
105
|
+
left: (props.width - props.bgWidth) / 2,
|
|
106
|
+
top: (props.height - props.bgHeight) / 2,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const getTargetTransform = (target) => {
|
|
110
|
+
return `translate3d(${
|
|
111
|
+
((-target.left - scaleOffset.left) / props.width) * 100
|
|
112
|
+
}%, ${((-target.top - scaleOffset.top) / props.height) * 100}%, 0) ${
|
|
113
|
+
baseScale.value
|
|
114
|
+
}`;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const appliedTrans = ref(getTargetTransform(curPosition));
|
|
118
|
+
const appliedAnim = ref(null);
|
|
119
|
+
|
|
120
|
+
//TODO JsvPreload 的回调会执行多次,所以需要一个标志来判断是否已经执行过
|
|
121
|
+
let loadDone = false;
|
|
122
|
+
|
|
123
|
+
const handlePreloadDone = (resultMap) => {
|
|
124
|
+
if (loadDone) return;
|
|
125
|
+
loadDone = true;
|
|
126
|
+
appliedTrans.value = getTargetTransform(curPosition);
|
|
127
|
+
isPreloadDone.value = true;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
let onAnimEnd = (normalEnd) => {
|
|
131
|
+
if (normalEnd) {
|
|
132
|
+
appliedTrans.value = getTargetTransform(curPosition);
|
|
133
|
+
}
|
|
134
|
+
appliedAnim.value = null;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
function slide(to) {
|
|
138
|
+
const prePosition = {
|
|
139
|
+
left: curPosition.left,
|
|
140
|
+
top: curPosition.top,
|
|
141
|
+
};
|
|
142
|
+
curPosition.left = to.left ?? prePosition.left;
|
|
143
|
+
curPosition.top = to.top ?? prePosition.top;
|
|
144
|
+
|
|
145
|
+
if (
|
|
146
|
+
prePosition.left === curPosition.left &&
|
|
147
|
+
prePosition.top === curPosition.top
|
|
148
|
+
) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
appliedTrans.value = null;
|
|
153
|
+
appliedAnim.value = `{from {transform: ${getTargetTransform(
|
|
154
|
+
prePosition
|
|
155
|
+
)};} to {transform: ${getTargetTransform(curPosition)};}}`;
|
|
156
|
+
pandaAnim.value.start(appliedAnim.value);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
defineExpose({
|
|
160
|
+
slide,
|
|
161
|
+
});
|
|
162
|
+
</script>
|