@shijiu/jsview-vue 2.1.200 → 2.1.340-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/bin/browser/BrowserApic.vue.mjs +124 -0
- package/bin/browser/BrowserApic2.vue.mjs +118 -0
- package/bin/browser/BrowserApicLib.mjs +424 -0
- package/bin/browser/BrowserAudio.vue.mjs +263 -0
- package/bin/browser/BrowserJsvLatex.vue.mjs +110 -0
- package/bin/browser/BrowserJsvPlayer.vue.mjs +573 -0
- package/bin/browser/BrowserPreload.vue.mjs +154 -0
- package/bin/browser/BrowserQrcode.vue.mjs +178 -0
- package/bin/browser/BrowserSpray.vue.mjs +66 -0
- package/bin/browser/BrowserTextureAnim.vue.mjs +324 -0
- package/bin/export-sfc.mjs +12 -0
- package/bin/jsview-common.mjs +39 -0
- package/bin/jsview-vue.mjs +21106 -0
- package/index.js +3 -4
- package/package.json +1 -2
- package/tools/config/rollup.config.mjs +52 -0
- package/tools/config/tsconfig.json +18 -0
- package/tools/config/vite.config.ts +60 -0
- package/tools/jsview-vue-build.mjs +125 -0
- package/utils/JsViewEngineWidget/{JsvFocusBlock.vue → JsvFocus/JsvFocusBlock.vue} +11 -11
- package/utils/JsViewEngineWidget/{JsvFocusHub.ts → JsvFocus/JsvFocusHub.ts} +9 -3
- package/utils/JsViewEngineWidget/{JsvFocusManager.js → JsvFocus/JsvFocusManager.js} +6 -5
- package/utils/JsViewEngineWidget/MetroWidget/AnimationManager.ts +33 -10
- package/utils/JsViewEngineWidget/MetroWidget/ListWidget.vue +89 -57
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +118 -62
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidgetSetup.js +504 -60
- package/utils/JsViewEngineWidget/MetroWidget/RenderItem.ts +11 -1
- package/utils/JsViewEngineWidget/MetroWidget/SlotComponent.vue +13 -0
- package/utils/JsViewEngineWidget/TemplateParser/CommonMetroTemplate.ts +1 -1
- package/utils/JsViewEngineWidget/TemplateParser/ListMetroTemplate.ts +1 -1
- package/utils/JsViewEngineWidget/TemplateParser/MetroTemplate.ts +34 -1
- package/utils/JsViewEngineWidget/TemplateParser/TemplateItemAdder.ts +52 -11
- package/utils/JsViewEngineWidget/index.js +3 -3
- package/utils/JsViewPlugin/JsvAudio/AudioProxy.js +9 -0
- package/utils/JsViewPlugin/JsvAudio/BrowserAudio/BrowserAudio.vue +11 -3
- package/utils/JsViewPlugin/JsvAudio/JsvAudio.vue +1 -0
- package/utils/JsViewPlugin/JsvAudio/JsvAudioBridgeProxy.js +8 -0
- package/utils/JsViewPlugin/JsvAudio/ScreenLockManager.js +16 -0
- package/utils/JsViewPlugin/JsvAudio/version.js +3 -3
- package/utils/JsViewPlugin/JsvAudio/version.mjs +3 -3
- package/utils/JsViewPlugin/JsvLatex/index.js +1 -1
- package/utils/JsViewPlugin/JsvPlayer/JsvPlayer.vue +1 -1
- package/utils/JsViewPlugin/JsvPlayer/index-0.9.js +3 -3
- package/utils/JsViewPlugin/JsvPlayer/index.js +2 -2
- package/utils/JsViewVueTools/DebugTool.js +2 -2
- package/utils/JsViewVueTools/DefaultKeyMap.js +1 -1
- package/utils/JsViewVueTools/JsvDynamicCssStyle.js +1 -1
- package/utils/JsViewVueTools/JsvDynamicKeyFrames.js +2 -2
- package/utils/JsViewVueTools/JsvImpactTracer.js +7 -7
- package/utils/JsViewVueTools/JsvPreDownloader.ts +1 -1
- package/utils/JsViewVueTools/JsvRefTaker.js +2 -1
- package/utils/JsViewVueTools/JsvRuntimeBridge.js +29 -29
- package/utils/JsViewVueTools/JsvStyleClass.js +3 -3
- package/utils/JsViewVueTools/JsvStyleSheetsDeclarer.js +1 -1
- package/utils/JsViewVueTools/JsvTextTools.js +4 -4
- package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/CanvasTexture.ts +29 -1
- package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/CommandList.ts +6 -5
- package/utils/JsViewVueTools/JsvTextureStore/JsvTextureStore.ts +60 -2
- package/utils/JsViewVueTools/NinePatchHelper.js +1 -1
- package/utils/JsViewVueWidget/JsvActorMove/ActorControlBase.js +1 -1
- package/utils/JsViewVueWidget/JsvActorMove/JsvActorMoveControl.js +1 -1
- package/utils/JsViewVueWidget/JsvApic/{BrowserApic → JsvApic}/BrowserApic.vue +20 -23
- package/utils/JsViewVueWidget/JsvApic/{JsvApic.vue → JsvApic/JsvApic.vue} +3 -14
- package/utils/JsViewVueWidget/JsvApic/{index.js → JsvApic/index.js} +2 -4
- package/utils/JsViewVueWidget/JsvApic/JsvApic2/BrowserApic2.vue +116 -0
- package/utils/JsViewVueWidget/JsvApic/JsvApic2/JsvApic2.vue +137 -0
- package/utils/JsViewVueWidget/JsvApic/JsvApic2/index.js +17 -0
- package/utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/BrowserApicLib.js +4 -0
- package/utils/JsViewVueWidget/JsvApic/{BrowserApic → JsvBrowserApicLib}/NormalLoopTool.js +16 -18
- package/utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/PartLoopTool.js +90 -0
- package/utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/SingleLoopTool.js +17 -0
- package/utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/Viewer.js +111 -0
- package/utils/JsViewVueWidget/JsvApic/JsvCommonLoopToolBase.js +48 -0
- package/utils/JsViewVueWidget/JsvConnectLine/ArcLineManager.js +71 -0
- package/utils/JsViewVueWidget/JsvConnectLine/JsvConnectLine.vue +354 -0
- package/utils/JsViewVueWidget/JsvConnectLine/index.js +2 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ActorControl.ts +37 -18
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ForgeTypeDefine.ts +7 -3
- package/utils/JsViewVueWidget/JsvFreeMoveActor/FreeMoveActor.vue +28 -2
- package/utils/JsViewVueWidget/JsvFreeMoveActor/JsvEnvBlocker.vue +12 -5
- package/utils/JsViewVueWidget/JsvFreeMoveActor/NexusNode.ts +21 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetAction.ts +47 -59
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetCondition.ts +129 -12
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetState.ts +45 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/index.js +10 -2
- package/utils/JsViewVueWidget/JsvGrid.vue +1 -1
- package/utils/JsViewVueWidget/JsvHole.js +1 -1
- package/utils/JsViewVueWidget/JsvInput/JsvInput.vue +1 -1
- package/utils/JsViewVueWidget/JsvLine/JsvLine.vue +2 -2
- package/utils/JsViewVueWidget/JsvLine/LineManager.js +6 -4
- package/utils/JsViewVueWidget/JsvMarquee.vue +7 -4
- package/utils/JsViewVueWidget/JsvPieChart.vue +1 -1
- package/utils/JsViewVueWidget/JsvPreload/JsvPreload.vue +1 -1
- package/utils/JsViewVueWidget/JsvPreload/index.js +1 -1
- package/utils/JsViewVueWidget/JsvProgressBar.vue +172 -0
- package/utils/JsViewVueWidget/JsvQrcode/JsvQrcode.vue +0 -1
- package/utils/JsViewVueWidget/JsvQrcode/index.js +1 -1
- package/utils/JsViewVueWidget/JsvRadarChart.vue +1 -1
- package/utils/JsViewVueWidget/JsvScaleTextBox.vue +0 -2
- package/utils/JsViewVueWidget/JsvSector.vue +1 -1
- package/utils/JsViewVueWidget/JsvSoundPool.js +1 -1
- package/utils/JsViewVueWidget/JsvSpray/index.js +1 -1
- package/utils/JsViewVueWidget/JsvSpriteAnim/FrameBuidler.ts +235 -0
- package/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteAnim.vue +433 -401
- package/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteLoader.vue +120 -0
- package/utils/JsViewVueWidget/JsvSpriteAnim/index.js +2 -2
- package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +5 -5
- package/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue +425 -422
- package/utils/JsViewVueWidget/JsvVisibleSensor/index.js +1 -1
- package/utils/JsViewVueWidget/index.js +7 -3
- package/utils/index.js +4 -0
- package/utils/JsViewVueWidget/JsvApic/BrowserApic/LoopToolBase.js +0 -25
- package/utils/JsViewVueWidget/JsvApic/BrowserApic/PartLoopTool.js +0 -119
- package/utils/JsViewVueWidget/JsvApic/BrowserApic/Viewer.js +0 -106
- /package/utils/JsViewPlugin/JsvLatex/{JsvLatexBrowser.vue → BrowserJsvLatex.vue} +0 -0
- /package/utils/JsViewPlugin/JsvPlayer/{JsvPlayerBrowser-0.9.vue → BrowserJsvPlayer-0.9.vue} +0 -0
- /package/utils/JsViewPlugin/JsvPlayer/{JsvPlayerBrowser.vue → BrowserJsvPlayer.vue} +0 -0
- /package/utils/JsViewVueWidget/JsvApic/{BrowserApic → JsvBrowserApicLib}/ApicDataBase.js +0 -0
- /package/utils/JsViewVueWidget/JsvApic/{BrowserApic → JsvBrowserApicLib}/GifData.js +0 -0
- /package/utils/JsViewVueWidget/JsvApic/{BrowserApic → JsvBrowserApicLib}/WebpData.js +0 -0
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
|
|
16
16
|
<script setup>
|
|
17
17
|
import { Forge } from "@shijiu/jsview/dom/jsv-forge-define";
|
|
18
|
-
import { TextTools } from "../JsViewVueTools
|
|
19
|
-
import
|
|
18
|
+
import { TextTools } from "../JsViewVueTools";
|
|
19
|
+
import JsvVisibleSensor from "./JsvVisibleSensor";
|
|
20
|
+
import { getTextWidth } from "../JsViewVueTools"
|
|
20
21
|
import {
|
|
21
22
|
shallowRef,
|
|
22
23
|
computed,
|
|
@@ -188,7 +189,7 @@ const sureNum = () => {
|
|
|
188
189
|
}
|
|
189
190
|
} else {
|
|
190
191
|
text1.value = props.text;
|
|
191
|
-
text2.value=null
|
|
192
|
+
text2.value = null;
|
|
192
193
|
noSlide.value = true;
|
|
193
194
|
MoreLong.value = false;
|
|
194
195
|
normalSlide.value = false;
|
|
@@ -364,9 +365,11 @@ const runAnimation = () => {
|
|
|
364
365
|
}
|
|
365
366
|
}
|
|
366
367
|
};
|
|
368
|
+
let ComparingText = "";
|
|
367
369
|
watchEffect(() => {
|
|
368
370
|
//获取最新数据
|
|
369
|
-
if (props.text !==
|
|
371
|
+
if (props.text !== ComparingText) {
|
|
372
|
+
ComparingText = props.text;
|
|
370
373
|
const newText = props.text;
|
|
371
374
|
const newTextGap = props.textGap;
|
|
372
375
|
const newTextWidth = TextTools.getOneLineTextDrawWidth(
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
<script setup>
|
|
30
30
|
import { watch, reactive, nextTick } from "vue";
|
|
31
|
-
import
|
|
31
|
+
import JsvSector from "./JsvSector.vue";
|
|
32
32
|
const props = defineProps({
|
|
33
33
|
centerPosition: { type: Object, required: true },
|
|
34
34
|
data: { type: Array, required: true },
|
|
@@ -192,7 +192,7 @@ const _getPreloadViewIdList = () => {
|
|
|
192
192
|
(image_url.toLowerCase().indexOf(".webp") >= 0 ||
|
|
193
193
|
image_url.toLowerCase().indexOf(".gif") >= 0)
|
|
194
194
|
) {
|
|
195
|
-
texture = ForgeHandles.TextureManager.
|
|
195
|
+
texture = ForgeHandles.TextureManager.GetImage2(image_url, false);
|
|
196
196
|
} else {
|
|
197
197
|
texture = ForgeHandles.TextureManager.GetImage2(
|
|
198
198
|
image_url,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @LastEditTime: 2021-11-22 14:24:36
|
|
6
6
|
* @Description: file content
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
//! 考虑到.vue文件除了export default的component外,还有可能export其他对象,因此使用import * as
|
|
9
9
|
import * as JsvPreload from "./JsvPreload.vue";
|
|
10
10
|
|
|
11
11
|
let _JsvPreload;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* 【模块 export 内容】
|
|
3
|
+
* JsvProgressBar:Vue高阶组件,进度条组件。
|
|
4
|
+
* props说明:
|
|
5
|
+
* width {Number} (必填) 进度条总宽度
|
|
6
|
+
* height {Number} (必填) 进度条总宽度(也是圆的直径)
|
|
7
|
+
* bgcBefore {String} (必填) 进度条前景颜色
|
|
8
|
+
* bgcBehind {String} (必填) 进度条背景颜色
|
|
9
|
+
* aniTime {Number} (可选) 进度条变化的动画时间,单位:秒。
|
|
10
|
+
* progress {Number} (可选) 进度条的百分比进度。有效值:0-100
|
|
11
|
+
* isCanvas {Boolean} (可选) 进度条的展示样式:①点九 ②clipView 默认为true,即点九样式。
|
|
12
|
+
-->
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<!-- 点九进度条 -->
|
|
16
|
+
<div v-if="props.isCanvas">
|
|
17
|
+
<div v-show="isZero">
|
|
18
|
+
<JsvNinePatch
|
|
19
|
+
:style="{
|
|
20
|
+
left: 0,
|
|
21
|
+
top: 0,
|
|
22
|
+
width: realWidth,
|
|
23
|
+
height: props.height,
|
|
24
|
+
}"
|
|
25
|
+
:imageUrl="`jsvtexturestore://${sourceId}`"
|
|
26
|
+
:imageWidth="props.height"
|
|
27
|
+
:centerWidth="1"
|
|
28
|
+
:imageDspWidth="props.height - 2"
|
|
29
|
+
:borderOutset="2"
|
|
30
|
+
:animTime="props.aniTime"
|
|
31
|
+
:onTransitionEnd="myTransitionEnd"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
<div v-else>
|
|
36
|
+
<div
|
|
37
|
+
:style="{
|
|
38
|
+
width: realWidth,
|
|
39
|
+
height: props.height,
|
|
40
|
+
top: 0,
|
|
41
|
+
left: 0,
|
|
42
|
+
borderRadius: radius,
|
|
43
|
+
transition: myTransition(),
|
|
44
|
+
overflow: 'hidden',
|
|
45
|
+
}"
|
|
46
|
+
>
|
|
47
|
+
<div
|
|
48
|
+
:style="{
|
|
49
|
+
left: 0,
|
|
50
|
+
width: props.width,
|
|
51
|
+
height: props.height,
|
|
52
|
+
top: 0,
|
|
53
|
+
borderRadius: radius,
|
|
54
|
+
backgroundColor: props.bgcBefore,
|
|
55
|
+
}"
|
|
56
|
+
></div>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
<!-- 点九背景 -->
|
|
60
|
+
<JsvNinePatch
|
|
61
|
+
:style="{
|
|
62
|
+
left: 0,
|
|
63
|
+
top: 0,
|
|
64
|
+
width: props.width,
|
|
65
|
+
height: props.height,
|
|
66
|
+
}"
|
|
67
|
+
:imageUrl="`jsvtexturestore://${sourceId2}`"
|
|
68
|
+
:imageWidth="props.height"
|
|
69
|
+
:centerWidth="1"
|
|
70
|
+
:imageDspWidth="props.height - 2"
|
|
71
|
+
:borderOutset="2"
|
|
72
|
+
:animTime="0"
|
|
73
|
+
/>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<script setup>
|
|
77
|
+
|
|
78
|
+
import JsvNinePatch from "../JsViewVueWidget/JsvNinePatch.vue";
|
|
79
|
+
import { shallowRef, onBeforeUnmount, watchEffect } from "vue";
|
|
80
|
+
import { JsvTextureStoreApi } from "../JsViewVueTools/JsvTextureStore/JsvTextureStore";
|
|
81
|
+
|
|
82
|
+
const props = defineProps({
|
|
83
|
+
width: { type: Number, required: true },
|
|
84
|
+
height: { type: Number, required: true },
|
|
85
|
+
bgcBefore: { type: String, required: true },
|
|
86
|
+
bgcBehind: { type: String, required: true },
|
|
87
|
+
aniTime: { type: Number, default: 0 },
|
|
88
|
+
progress: { type: Number, required: true },
|
|
89
|
+
isCanvas: { type: Boolean, default: true },
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
let canvasRef;
|
|
93
|
+
let canvasRef2;
|
|
94
|
+
let sourceId = shallowRef("");
|
|
95
|
+
let sourceId2 = shallowRef("");
|
|
96
|
+
|
|
97
|
+
//画布大小
|
|
98
|
+
let bitmap = {
|
|
99
|
+
width: props.height,
|
|
100
|
+
height: props.height,
|
|
101
|
+
};
|
|
102
|
+
//半径
|
|
103
|
+
let radius = Math.floor(props.height / 2) - 2;
|
|
104
|
+
|
|
105
|
+
//相应Texture赋值
|
|
106
|
+
canvasRef = JsvTextureStoreApi.canvasTexture(bitmap.width, bitmap.height);
|
|
107
|
+
canvasRef2 = JsvTextureStoreApi.canvasTexture(bitmap.width, bitmap.height);
|
|
108
|
+
|
|
109
|
+
//让progress有响应式
|
|
110
|
+
let myProgress = shallowRef(props.progress);
|
|
111
|
+
|
|
112
|
+
//初始值
|
|
113
|
+
let realWidth = shallowRef(0);
|
|
114
|
+
|
|
115
|
+
//当展示点九时,控制CanvasTexture显示的数值
|
|
116
|
+
let isZero = shallowRef(true);
|
|
117
|
+
//画图
|
|
118
|
+
let customPath = canvasRef.circlePath(radius + 2, radius + 2, radius);
|
|
119
|
+
let customPath2 = canvasRef2.circlePath(radius + 2, radius + 2, radius);
|
|
120
|
+
customPath.fill(props.bgcBefore);
|
|
121
|
+
customPath2.fill(props.bgcBehind);
|
|
122
|
+
sourceId.value = canvasRef.commit();
|
|
123
|
+
sourceId2.value = canvasRef2.commit();
|
|
124
|
+
|
|
125
|
+
//点九控制百分比为0的函数
|
|
126
|
+
const myTransitionEnd = () => {
|
|
127
|
+
if (myProgress.value <= 0) {
|
|
128
|
+
isZero.value = false;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
//clipView控制动画的函数
|
|
132
|
+
const myTransition = () => {
|
|
133
|
+
if (props.aniTime !== 0) {
|
|
134
|
+
return `width ${props.aniTime}s linear`;
|
|
135
|
+
} else {
|
|
136
|
+
return "";
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
watchEffect(() => {
|
|
140
|
+
//限制最高值和最低值
|
|
141
|
+
if (props.progress >= 100) {
|
|
142
|
+
myProgress.value = 100;
|
|
143
|
+
realWidth.value = props.width;
|
|
144
|
+
isZero.value = true;
|
|
145
|
+
} else if (props.progress <= 0) {
|
|
146
|
+
myProgress.value = 0;
|
|
147
|
+
if (props.isCanvas) {
|
|
148
|
+
realWidth.value = props.height;
|
|
149
|
+
} else {
|
|
150
|
+
realWidth.value = 0;
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
myProgress.value = props.progress;
|
|
154
|
+
if (props.isCanvas) {
|
|
155
|
+
realWidth.value = Math.floor(
|
|
156
|
+
(props.width - props.height) * myProgress.value * 0.01 + props.height
|
|
157
|
+
);
|
|
158
|
+
isZero.value = true;
|
|
159
|
+
} else {
|
|
160
|
+
realWidth.value = Math.floor(props.width * myProgress.value * 0.01);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
//页面卸载前删除Texture
|
|
166
|
+
onBeforeUnmount(() => {
|
|
167
|
+
JsvTextureStoreApi?.deleteTexture(sourceId.value);
|
|
168
|
+
JsvTextureStoreApi?.deleteTexture(sourceId2.value);
|
|
169
|
+
});
|
|
170
|
+
</script>
|
|
171
|
+
|
|
172
|
+
<style lang="scss" scoped></style>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @LastEditTime: 2021-10-13 17:41:34
|
|
6
6
|
* @Description: file content
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
//! 考虑到.vue文件除了export default的component外,还有可能export其他对象,因此使用import * as
|
|
9
9
|
import * as JsvQrcode from "./JsvQrcode.vue";
|
|
10
10
|
|
|
11
11
|
let _JsvQrcode;
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
-->
|
|
18
18
|
<script setup>
|
|
19
19
|
import { shallowRef, onMounted, onBeforeUnmount, watch, ref, onBeforeUpdate } from "vue"
|
|
20
|
-
import { getTextWidth } from "
|
|
20
|
+
import { getTextWidth } from "../JsViewVueTools"
|
|
21
21
|
const props = defineProps({
|
|
22
22
|
style: {
|
|
23
23
|
type: Object,
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
|
|
69
69
|
<script setup>
|
|
70
70
|
import { shallowRef, onBeforeUnmount, watch } from "vue";
|
|
71
|
-
import { JsvTextureStoreApi
|
|
71
|
+
import { JsvTextureStoreApi } from "../JsViewVueTools";
|
|
72
72
|
let sourceId = shallowRef("");
|
|
73
73
|
const props = defineProps({
|
|
74
74
|
centerPosition: { type: Object, require: true },
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @LastEditTime: 2021-10-18 14:09:04
|
|
6
6
|
* @Description: file content
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
//! 考虑到.vue文件除了export default的component外,还有可能export其他对象,因此使用import * as
|
|
9
9
|
import * as JsvSpray from "./JsvSpray.vue";
|
|
10
10
|
let _JsvSpray;
|
|
11
11
|
if (window.JsView) {
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { getKeyFramesGroup } from "../../JsViewVueTools/JsvDynamicKeyFrames.js";
|
|
2
|
+
import { getsAnimationToken } from "./sAnimationToken.js";
|
|
3
|
+
|
|
4
|
+
let keyFrameStyleSheet = getKeyFramesGroup(null);
|
|
5
|
+
|
|
6
|
+
const TRANSFORM_ORIGIN_LEFT_TOP: String = "left top";
|
|
7
|
+
|
|
8
|
+
class TransformInfoResule {
|
|
9
|
+
public csw: number = 1;
|
|
10
|
+
public csh: number = 1;
|
|
11
|
+
public cx: number = 0;
|
|
12
|
+
public cy: number = 0;
|
|
13
|
+
public sw: number = 1;
|
|
14
|
+
public sh: number = 1;
|
|
15
|
+
public x: number = 0;
|
|
16
|
+
public y: number = 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class SpritePack {
|
|
20
|
+
public keyFrameRefName: String | null = null;
|
|
21
|
+
public clipKeyFrameName: String | null = null;
|
|
22
|
+
public transKeyFrameName: String | null = null;
|
|
23
|
+
public clipStyle: any = null; // 对应clip div的style控制
|
|
24
|
+
public transStyle: any = null; // 对应translate div的style控制
|
|
25
|
+
public imageStyle: any = null; // 对应最内部的图片展示的div的style控制
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getAnimNameBase() {
|
|
29
|
+
return `sprite-anim-name-${getsAnimationToken()}`;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function getTransformInfo(
|
|
33
|
+
source_obj: any,
|
|
34
|
+
target_obj: any,
|
|
35
|
+
canvas_width: number,
|
|
36
|
+
canvas_height: number
|
|
37
|
+
): TransformInfoResule {
|
|
38
|
+
const result = new TransformInfoResule();
|
|
39
|
+
|
|
40
|
+
// Clip在Canvas div之内,以Canvas为基准进行缩放和平移
|
|
41
|
+
// 图形左上角远离原点后再缩放,所以需要进行缩放补偿
|
|
42
|
+
const clip_scale_w: number = target_obj.w / canvas_width;
|
|
43
|
+
const clip_scale_h: number = target_obj.h / canvas_height;
|
|
44
|
+
result.csw = clip_scale_w;
|
|
45
|
+
result.csh = clip_scale_h;
|
|
46
|
+
result.cx = target_obj.x / clip_scale_w;
|
|
47
|
+
result.cy = target_obj.y / clip_scale_h;
|
|
48
|
+
|
|
49
|
+
// Image在Clip div之内,所以以Clip为基准进行缩放和平移, 对clip的缩放进行反处理以还原尺寸
|
|
50
|
+
// 将子图左上角对齐原点后再缩放,所以x,y不需要进行举例缩放补偿
|
|
51
|
+
result.sw = source_obj.w / target_obj.w / clip_scale_w;
|
|
52
|
+
result.sh = source_obj.h / target_obj.h / clip_scale_h;
|
|
53
|
+
result.x = -source_obj.x;
|
|
54
|
+
result.y = -source_obj.y;
|
|
55
|
+
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
function createTransformStyle(
|
|
60
|
+
w_scale: number,
|
|
61
|
+
h_scale: number,
|
|
62
|
+
x: number,
|
|
63
|
+
y: number
|
|
64
|
+
): String {
|
|
65
|
+
let output = "";
|
|
66
|
+
output =
|
|
67
|
+
`${output}scale3d(${parseFloat(w_scale as any).toPrecision(5)},${parseFloat(h_scale as any).toPrecision(5)},1) `
|
|
68
|
+
+ `translate3d(${parseFloat(x as any).toPrecision(5)}px,${parseFloat(y as any).toPrecision(5)}px,0)`;
|
|
69
|
+
return output;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
function expireAnimates(runningSprite: SpritePack | null) {
|
|
73
|
+
if (!runningSprite) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
let keyFrameRefName = runningSprite.keyFrameRefName;
|
|
77
|
+
const names_array = [`${keyFrameRefName}-clip`, `${keyFrameRefName}-image`];
|
|
78
|
+
|
|
79
|
+
if (keyFrameStyleSheet) {
|
|
80
|
+
keyFrameStyleSheet.removeMultiRules(names_array);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function newAnimateFrames(
|
|
85
|
+
image_url: string,
|
|
86
|
+
frame_info_list: Array<any> | undefined,
|
|
87
|
+
canvas_width: number,
|
|
88
|
+
canvas_height: number,
|
|
89
|
+
source_width: number,
|
|
90
|
+
source_height: number,
|
|
91
|
+
): SpritePack {
|
|
92
|
+
|
|
93
|
+
if (!frame_info_list || frame_info_list.length == 0) {
|
|
94
|
+
return new SpritePack();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!keyFrameStyleSheet) {
|
|
98
|
+
console.error("Error: Get keyFrameStyleSheet failed");
|
|
99
|
+
return new SpritePack();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const frame_percent = 1 / (frame_info_list.length - 1);
|
|
103
|
+
const anim_base_name = getAnimNameBase();
|
|
104
|
+
const anim_name_clip = `${anim_base_name}-clip`;
|
|
105
|
+
const anim_name_image = `${anim_base_name}-image`;
|
|
106
|
+
let image_keyframs = `@keyframes ${anim_name_image} {`;
|
|
107
|
+
let clip_keyframs = `@keyframes ${anim_name_clip} {`;
|
|
108
|
+
|
|
109
|
+
for (let i = 0; i < frame_info_list.length; i++) {
|
|
110
|
+
let item: any;
|
|
111
|
+
item = frame_info_list[i];
|
|
112
|
+
|
|
113
|
+
// Header
|
|
114
|
+
let header: String;
|
|
115
|
+
if (i !== frame_info_list.length) {
|
|
116
|
+
header = `${parseFloat((frame_percent * i * 100) as any).toFixed(2)}% {`;
|
|
117
|
+
} else {
|
|
118
|
+
header = "100% {";
|
|
119
|
+
}
|
|
120
|
+
image_keyframs += header;
|
|
121
|
+
clip_keyframs += header;
|
|
122
|
+
|
|
123
|
+
if (item.source) {
|
|
124
|
+
const tr = getTransformInfo(
|
|
125
|
+
item.source,
|
|
126
|
+
item.target,
|
|
127
|
+
canvas_width,
|
|
128
|
+
canvas_height
|
|
129
|
+
);
|
|
130
|
+
const clip_trans = createTransformStyle(tr.csw, tr.csh, tr.cx, tr.cy);
|
|
131
|
+
const image_trans = createTransformStyle(tr.sw, tr.sh, tr.x, tr.y);
|
|
132
|
+
|
|
133
|
+
let tr_str = "";
|
|
134
|
+
tr_str = `${tr_str}transform:${clip_trans};transform-origin:left top;`;
|
|
135
|
+
clip_keyframs += tr_str;
|
|
136
|
+
|
|
137
|
+
tr_str = "";
|
|
138
|
+
tr_str = `${tr_str}transform:${image_trans};transform-origin:left top;`;
|
|
139
|
+
image_keyframs += tr_str;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
image_keyframs += "}";
|
|
143
|
+
clip_keyframs += "}";
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
image_keyframs += "}";
|
|
147
|
+
clip_keyframs += "}";
|
|
148
|
+
|
|
149
|
+
// 申请全局keyFrame
|
|
150
|
+
keyFrameStyleSheet.insertRule(image_keyframs);
|
|
151
|
+
keyFrameStyleSheet.insertRule(clip_keyframs);
|
|
152
|
+
|
|
153
|
+
let pack_info = new SpritePack();
|
|
154
|
+
|
|
155
|
+
// console.log("testSprite image_keyframs", image_keyframs)
|
|
156
|
+
// console.log("testSprite clip_keyframs", clip_keyframs)
|
|
157
|
+
|
|
158
|
+
pack_info.keyFrameRefName = anim_base_name;
|
|
159
|
+
pack_info.clipKeyFrameName = anim_name_clip;
|
|
160
|
+
pack_info.clipStyle = {
|
|
161
|
+
overflow: "hidden",
|
|
162
|
+
width: canvas_width,
|
|
163
|
+
height: canvas_height,
|
|
164
|
+
transform: null, // 重置 transform,以免影响keyframe动画
|
|
165
|
+
transformOrigin: TRANSFORM_ORIGIN_LEFT_TOP,
|
|
166
|
+
animation: null, // 外部设置,需要时间和loop信息
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
pack_info.transKeyFrameName = anim_name_image;
|
|
170
|
+
pack_info.transStyle = {
|
|
171
|
+
transform: null, // 重置 transform,以免影响keyframe动画
|
|
172
|
+
transformOrigin: TRANSFORM_ORIGIN_LEFT_TOP,
|
|
173
|
+
animation: null, // 外部设置,需要时间和loop信息
|
|
174
|
+
width: source_width,
|
|
175
|
+
height: source_height,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
pack_info.imageStyle = {
|
|
179
|
+
backgroundImage: image_url,
|
|
180
|
+
width: source_width,
|
|
181
|
+
height: source_height,
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
return pack_info;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function newFrozeFrame(
|
|
188
|
+
image_url: String,
|
|
189
|
+
frame_info_list: Array<any>, // 精灵图队列
|
|
190
|
+
index: number, // 静止帧 stopFrame.value === "start" ? 0 : frame_info_list.length - 1;
|
|
191
|
+
canvas_width: number,
|
|
192
|
+
canvas_height: number,
|
|
193
|
+
source_width: number,
|
|
194
|
+
source_height: number
|
|
195
|
+
): SpritePack {
|
|
196
|
+
let sprite_info = new SpritePack();
|
|
197
|
+
|
|
198
|
+
const tr = getTransformInfo(
|
|
199
|
+
frame_info_list[index].source,
|
|
200
|
+
frame_info_list[index].target,
|
|
201
|
+
canvas_width,
|
|
202
|
+
canvas_height
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
sprite_info.clipStyle = {
|
|
206
|
+
transform: createTransformStyle(tr.csw, tr.csh, tr.cx, tr.cy),
|
|
207
|
+
transformOrigin: TRANSFORM_ORIGIN_LEFT_TOP,
|
|
208
|
+
overflow: "hidden",
|
|
209
|
+
left: 0,
|
|
210
|
+
top: 0,
|
|
211
|
+
width: canvas_width,
|
|
212
|
+
height: canvas_height,
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
sprite_info.transStyle = {
|
|
216
|
+
transformOrigin: TRANSFORM_ORIGIN_LEFT_TOP,
|
|
217
|
+
transform: createTransformStyle(tr.sw, tr.sh, tr.x, tr.y),
|
|
218
|
+
width: source_width,
|
|
219
|
+
height: source_height,
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
sprite_info.imageStyle = {
|
|
223
|
+
backgroundImage: image_url,
|
|
224
|
+
width: source_width,
|
|
225
|
+
height: source_height,
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
return sprite_info;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export {
|
|
232
|
+
expireAnimates,
|
|
233
|
+
newAnimateFrames,
|
|
234
|
+
newFrozeFrame
|
|
235
|
+
}
|