@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.
- package/BakeViewDemo/AnimatePic.vue +1 -1
- package/Basic/components/text/TextDirection.vue +7 -1
- package/BasicFocusControl/components/BaseBlock.vue +65 -18
- package/BreakRender/assets/imageList.json +235 -235
- package/ColorSpace/App.vue +2 -2
- package/CoupletsTest/App.vue +1 -1
- package/CoupletsTest/widget/Banger/Banger.vue +3 -3
- package/CoupletsTest/widget/Banger/MaroonLoader.vue +5 -5
- package/CoupletsTest/widget/Couplets/Couplets.vue +4 -4
- package/CoupletsTest/widget/Fireworks/Fireworks.vue +13 -13
- package/CustomShader/App.vue +4 -4
- package/CustomShader/gaussianBlur.glsl +1 -1
- package/DashPath/App.vue +80 -0
- package/DashPath/AppForOperator.vue +33 -0
- package/DemoForOperator/AnimPic/AnimPic.vue +69 -0
- package/DemoForOperator/AnimPic/App.vue +28 -0
- package/DemoForOperator/Banger/App.vue +26 -0
- package/DemoForOperator/Banger/Banger/Banger.vue +316 -0
- package/DemoForOperator/Banger/Banger/Maroon.vue +123 -0
- package/DemoForOperator/Banger/Banger/MaroonLoader.vue +78 -0
- package/DemoForOperator/Banger/Banger/SpriteDeal.js +30 -0
- 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/App.vue +43 -0
- package/DemoForOperator/Bounce/Bounce.vue +81 -0
- package/DemoForOperator/Bounce/FreeMoveBuilder.js +139 -0
- package/DemoForOperator/ChunLian/App.vue +47 -0
- package/DemoForOperator/ChunLian/Couplets.vue +291 -0
- package/DemoForOperator/ClickSpriteAnim/App.vue +130 -0
- package/DemoForOperator/ClickSpriteAnim/Item.vue +74 -0
- package/DemoForOperator/DominantColor/App.vue +187 -0
- package/DemoForOperator/EpisodeList/App.vue +80 -0
- package/DemoForOperator/EpisodeList/EpisodeList/Controller.vue +110 -0
- package/DemoForOperator/EpisodeList/EpisodeList/EpisodeList.vue +250 -0
- package/DemoForOperator/EpisodeList/GroupItem.vue +65 -0
- package/DemoForOperator/EpisodeList/ListItem.vue +48 -0
- package/DemoForOperator/Firework1/App.vue +25 -0
- package/DemoForOperator/Firework1/Fireworks.vue +397 -0
- package/DemoForOperator/Firework1/SpriteDeal.js +30 -0
- package/DemoForOperator/FlipPage/App.vue +75 -0
- package/DemoForOperator/FlipPage/FlipPage/FlipPage.vue +178 -0
- package/DemoForOperator/FlipPage/FlipPage/flipIn.glsl +41 -0
- package/DemoForOperator/FlipPage/FlipPage/flipOut.glsl +41 -0
- package/DemoForOperator/Focus/Alpha/AlphaFocusBox.vue +95 -0
- package/DemoForOperator/Focus/Alpha/AlphaPage.vue +40 -0
- package/DemoForOperator/Focus/Alpha/Item.vue +64 -0
- package/DemoForOperator/Focus/App.vue +124 -0
- package/DemoForOperator/Focus/CommonPageSetting.js +30 -0
- package/DemoForOperator/Focus/Item.vue +46 -0
- package/DemoForOperator/Focus/Light/Item.vue +67 -0
- package/DemoForOperator/Focus/Light/LightFocusBox.vue +87 -0
- package/DemoForOperator/Focus/Light/LightPage.vue +43 -0
- package/DemoForOperator/Focus/Light/utils/FrameCanvasStore.ts +68 -0
- package/DemoForOperator/Focus/Light/utils/RotateFrame.vue +146 -0
- package/DemoForOperator/Focus/Light/utils/circleHaloMask.png +0 -0
- package/DemoForOperator/Focus/Normal/Item.vue +64 -0
- package/DemoForOperator/Focus/Normal/NormalFocusBox.vue +65 -0
- package/DemoForOperator/Focus/Normal/NormalPage.vue +41 -0
- package/DemoForOperator/Focus/SwipeLight/Item.vue +73 -0
- package/DemoForOperator/Focus/SwipeLight/SwipeLightBox.vue +62 -0
- package/DemoForOperator/Focus/SwipeLight/SwipeLightPage.vue +44 -0
- package/DemoForOperator/FrameShadow/App.vue +193 -0
- package/DemoForOperator/FrameShadow/FrameShadow.vue +61 -0
- package/DemoForOperator/FullscreenIn/App.vue +105 -0
- package/DemoForOperator/FullscreenIn/FullscreenPoster.vue +56 -0
- package/DemoForOperator/FullscreenIn/Item.vue +50 -0
- package/DemoForOperator/Genie/App.vue +78 -0
- package/DemoForOperator/Genie/geniePakcer/Genie.vue +741 -0
- package/DemoForOperator/Genie/geniePakcer/genieBottom.glsl +49 -0
- package/DemoForOperator/Genie/geniePakcer/genieLeft.glsl +50 -0
- package/DemoForOperator/Genie/geniePakcer/genieRight.glsl +57 -0
- package/DemoForOperator/Genie/geniePakcer/genieTop.glsl +50 -0
- package/DemoForOperator/GrayFilter/App.vue +51 -0
- package/DemoForOperator/GrayFilter/GrayFilter.vue +59 -0
- package/DemoForOperator/Jigsaw/App.vue +45 -0
- package/DemoForOperator/Jigsaw/JigsawFull.vue +142 -0
- package/DemoForOperator/Jigsaw/JigsawSingle.vue +118 -0
- 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/App.vue +69 -0
- package/DemoForOperator/Particle/Drop/DropParticle.vue +208 -0
- package/DemoForOperator/Particle/Explode/ExplodeParticle.vue +120 -0
- package/DemoForOperator/PosterAnim/App.vue +125 -0
- package/DemoForOperator/PosterAnim/Bounce/BouncePage.vue +54 -0
- package/DemoForOperator/PosterAnim/Bounce/Item.vue +85 -0
- package/DemoForOperator/PosterAnim/Breath/BreathPage.vue +47 -0
- package/DemoForOperator/PosterAnim/Breath/Item.vue +58 -0
- package/DemoForOperator/PosterAnim/CommonPageSetting.js +30 -0
- package/DemoForOperator/PosterAnim/Item.vue +46 -0
- package/DemoForOperator/PosterAnim/PosterAnim.js +79 -0
- package/DemoForOperator/PosterAnim/Scale/Item.vue +72 -0
- package/DemoForOperator/PosterAnim/Scale/ScalePage.vue +48 -0
- package/DemoForOperator/PosterAnim/Shake/Item.vue +85 -0
- package/DemoForOperator/PosterAnim/Shake/ShakePage.vue +53 -0
- package/DemoForOperator/PosterOverflow/App.vue +116 -0
- package/DemoForOperator/PosterOverflow/Item.vue +67 -0
- package/DemoForOperator/PosterOverflow/PosterOverflow.vue +39 -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/App.vue +54 -0
- package/DemoForOperator/Ripple/Ripple.vue +65 -0
- 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/App.vue +33 -0
- package/DemoForOperator/Sprite/Sprite.vue +147 -0
- package/DemoForOperator/Stretch/App.vue +103 -0
- package/DemoForOperator/Stretch/Stretch/Item.vue +192 -0
- package/DemoForOperator/Stretch/Stretch/Stretch.vue +218 -0
- package/DemoForOperator/Swiper/App.vue +101 -0
- package/DemoForOperator/Swiper/Item.vue +56 -0
- package/DemoForOperator/Swiper/ParallaxSlide.vue +164 -0
- package/DemoForOperator/TabContent/App.vue +89 -0
- package/DemoForOperator/TabContent/ContentPage.vue +66 -0
- package/DemoForOperator/TabContent/Item.vue +85 -0
- package/DemoForOperator/TabContent/PageItem.vue +40 -0
- package/DemoForOperator/TabContent/TabContent/CreepFocus.vue +160 -0
- package/DemoForOperator/TabContent/TabContent/Item.vue +63 -0
- package/DemoForOperator/TabContent/TabContent/TabContent.vue +184 -0
- package/DemoForOperator/TabContent/TabContent/TabItem.vue +368 -0
- package/DemoForOperator/TabContent/TabContent/TabWidget.vue +243 -0
- package/DemoForOperator/TabContent/TabContent/Util.js +3 -0
- package/DemoForOperator/TabContent/TabContent/ViewSwiper.vue +110 -0
- package/DemoForOperator/TabContent/testData.js +241 -0
- 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/App.vue +78 -0
- package/DemoForOperator/Vortex/Vortex/Vortex.vue +180 -0
- package/DemoForOperator/Vortex/Vortex/vortexIn.glsl +38 -0
- package/DemoForOperator/Vortex/Vortex/vortexOut.glsl +38 -0
- package/DemoForOperator/index.js +6 -0
- package/DemoForOperator/routeList.js +259 -0
- package/DemoHomepage/App.vue +50 -30
- package/DemoHomepage/components/Dialog.vue +1 -0
- package/DemoHomepage/components/Item.vue +11 -0
- package/DemoHomepage/components/TabFrame.vue +7 -0
- package/DemoHomepage/router.js +178 -81
- package/DemoHomepage/views/Homepage.vue +7 -2
- package/DivMetroPerformance/data.js +3 -3
- package/DriftScopeTest/App.vue +1 -1
- package/FilterDemo/AnimatePic.vue +1 -1
- package/FilterDemo/VideoLayer.vue +2 -2
- package/FullScreenFlex/TestFrame2.vue +1 -1
- package/GiftRain/App.vue +12 -12
- package/GiftRain/components/SpriteTranslate.vue +68 -48
- package/HashHistory/App.vue +2 -2
- package/HashHistory/router.js +1 -1
- package/JsvPreDownloader/App.vue +4 -4
- package/MediaDemo/components/frames/AudioFrame.vue +1 -1
- package/MediaDemo/components/frames/VideoFrame.vue +1 -1
- package/MetroWidgetDemos/MassiveItems/ContentItem.vue +1 -1
- package/MetroWidgetDemos/MassiveItems/data.js +1 -1
- package/MetroWidgetDemos/PerformanceTest/data.js +3 -3
- package/MetroWidgetDemos/RefreshDemo/assets/imageList.json +235 -235
- package/MetroWidgetDemos/SkeletonDiagram/assets/imageList.json +235 -235
- 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/focusableItemMetroWidget/WidgetItem.vue +3 -1
- package/MetroWidgetDemos/routeList.js +34 -17
- package/Poster3d/App.vue +69 -0
- package/Poster3d/Poster3d.vue +92 -0
- package/PosterPacker/App.vue +5 -5
- package/PosterPacker/tools/vortexPacker/Vortex.vue +1 -1
- package/QrcodeDemo/App.vue +1 -1
- package/Ripple/App.vue +1 -1
- package/ScaleDownNeon/App.vue +4 -4
- package/SceneTransition/App.vue +2 -2
- package/SceneTransition/maskConfig/config2.js +12 -12
- package/SceneTransition/maskConfig/config3.js +14 -14
- package/SprayView/App.vue +96 -51
- package/SpringFestival/App.vue +73 -0
- package/SpringFestival/SpringFestivalScene/ChunLian.vue +211 -0
- package/SpringFestival/SpringFestivalScene/FreeMoveBuilder.js +139 -0
- package/SpringFestival/SpringFestivalScene/LanternAnim.js +60 -0
- package/SpringFestival/SpringFestivalScene/Rain.vue +137 -0
- package/SpringFestival/SpringFestivalScene/Scene.vue +218 -0
- package/SpringFestival/SpringFestivalScene/imageConfig.js +87 -0
- package/SpringFestival/SpringFestivalScene/index.js +1 -0
- package/Swiper/App.vue +28 -29
- package/Swiper/Item.vue +19 -0
- package/SwiperTest/App.vue +9 -9
- package/TestNativeSharedView/AckEventDefine.ts +82 -0
- package/TestNativeSharedView/App.vue +4 -6
- package/TestNativeSharedView/JsvDemoTester.js +131 -0
- package/TextureAnimation/App.vue +16 -6
- package/TextureAnimation/App3.vue +100 -0
- package/TextureAnimation/utils/FrameCanvasStore.ts +68 -0
- package/TextureAnimation/utils/RotateFrame.vue +146 -0
- package/TextureAnimation/utils/circleHaloMask.png +0 -0
- package/TombSweepingDayTest/Raining/RainScene.vue +4 -4
- package/ViewOpacity/App.vue +21 -2
- package/package.json +1 -1
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { JsvTextureStoreApi } from "jsview";
|
|
3
|
+
|
|
4
|
+
const FLIP_STATUS_IDLE = 0;
|
|
5
|
+
const FLIP_STATUS_WAIT_DIV_READY = 1;
|
|
6
|
+
const FLIP_STATUS_TAKING = 2;
|
|
7
|
+
const FLIP_STATUS_READY = 3;
|
|
8
|
+
|
|
9
|
+
function takeTexture(pageDivRef, pageIndex) {
|
|
10
|
+
// 抓取界面
|
|
11
|
+
let holder = {
|
|
12
|
+
promiseRef: null,
|
|
13
|
+
textureRef: null,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
holder.promiseRef = new Promise((resolve, reject) => {
|
|
17
|
+
holder.textureRef = JsvTextureStoreApi.capture2Texture(
|
|
18
|
+
pageDivRef,
|
|
19
|
+
(textureAccessName) => {
|
|
20
|
+
if (textureAccessName != "") {
|
|
21
|
+
resolve(textureAccessName);
|
|
22
|
+
} else {
|
|
23
|
+
reject();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
return holder;
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<script setup>
|
|
33
|
+
import { computed, shallowRef, onUnmounted, onMounted, reactive } from "vue";
|
|
34
|
+
import pageFlipShader from "./flip.glsl?raw";
|
|
35
|
+
import { JsvFragShaderView } from "jsview";
|
|
36
|
+
|
|
37
|
+
// 定义组件的 props
|
|
38
|
+
const props = defineProps({
|
|
39
|
+
// 页面总数
|
|
40
|
+
pageCount: {
|
|
41
|
+
type: Number,
|
|
42
|
+
default: 2,
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
// 初始化时显示的页面索引
|
|
46
|
+
initPageIndex: {
|
|
47
|
+
type: Number,
|
|
48
|
+
default: 0,
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
// 组件的坐标 x,y
|
|
52
|
+
position: {
|
|
53
|
+
type: Object,
|
|
54
|
+
default: () => ({
|
|
55
|
+
x: 0,
|
|
56
|
+
y: 0,
|
|
57
|
+
}),
|
|
58
|
+
validator: (value) => {
|
|
59
|
+
return !isNaN(value.x) && !isNaN(value.y);
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
// page的width,height
|
|
64
|
+
pageSize: {
|
|
65
|
+
type: Object,
|
|
66
|
+
required: true,
|
|
67
|
+
validator: (value) => {
|
|
68
|
+
return !isNaN(value.width) && !isNaN(value.height);
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
// 动画持续时间
|
|
73
|
+
duration: {
|
|
74
|
+
type: Number,
|
|
75
|
+
default: 600,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const cFlipArea = {
|
|
80
|
+
width: Math.ceil(props.pageSize.width / 1.0),
|
|
81
|
+
height: Math.ceil(props.pageSize.height / 0.8),
|
|
82
|
+
x: 0,
|
|
83
|
+
y: 0,
|
|
84
|
+
};
|
|
85
|
+
// cFlipArea.x = Math.ceil((props.pageSize.width - cFlipArea.width) / 2); // 翻页区域对齐原div区域
|
|
86
|
+
// cFlipArea.y = Math.ceil((props.pageSize.height - cFlipArea.height) / 2); // 翻页区域对齐原div区域
|
|
87
|
+
|
|
88
|
+
// 创建rPageList数据,内容为shallowRef(null)
|
|
89
|
+
const rPageList = Array(props.pageCount)
|
|
90
|
+
.fill()
|
|
91
|
+
.map((_, idx) => ({
|
|
92
|
+
index: idx,
|
|
93
|
+
divRef: null,
|
|
94
|
+
pageReady: false,
|
|
95
|
+
}));
|
|
96
|
+
|
|
97
|
+
const rPageLives = reactive([props.initPageIndex, -1]);
|
|
98
|
+
|
|
99
|
+
const rCurrentPageIndex = shallowRef(props.initPageIndex);
|
|
100
|
+
|
|
101
|
+
const rPrevPageIndex = shallowRef(-1);
|
|
102
|
+
|
|
103
|
+
// fragShaderView的Texture管理
|
|
104
|
+
const rTextureStatus = shallowRef(FLIP_STATUS_IDLE);
|
|
105
|
+
const rTextureNames = [shallowRef(null), shallowRef(null)];
|
|
106
|
+
let vTextureHolder = {
|
|
107
|
+
holder0: null,
|
|
108
|
+
holder1: null,
|
|
109
|
+
token: 0,
|
|
110
|
+
};
|
|
111
|
+
let vTexturePromiseAll = null;
|
|
112
|
+
|
|
113
|
+
const rPageFlipSettings = computed(() => {
|
|
114
|
+
return {
|
|
115
|
+
name: "pageFlip",
|
|
116
|
+
shader: pageFlipShader,
|
|
117
|
+
uniforms: [],
|
|
118
|
+
textures: [
|
|
119
|
+
{
|
|
120
|
+
name: "iChannel0",
|
|
121
|
+
resource: "jsvtexturestore://" + rTextureNames[1].value,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "iChannel1",
|
|
125
|
+
resource: "jsvtexturestore://" + rTextureNames[0].value,
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
duration: props.duration,
|
|
129
|
+
onEnd: (end_or_cancel) => {
|
|
130
|
+
// 结束动画, 以触发prev页面的销毁
|
|
131
|
+
if (rTextureStatus.value == FLIP_STATUS_READY) {
|
|
132
|
+
// 非开新界面时,结束动画后,恢复到空闲状态
|
|
133
|
+
rTextureStatus.value = FLIP_STATUS_IDLE;
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// 新进界面触发flush处理,第一个flush传来后才启动动画
|
|
140
|
+
const fncTriggerFlush = (pageIndex) => {
|
|
141
|
+
rPageList[pageIndex].pageReady = true;
|
|
142
|
+
|
|
143
|
+
// prev和current的page都ready了就启动翻页动画
|
|
144
|
+
if (
|
|
145
|
+
rTextureStatus.value == FLIP_STATUS_WAIT_DIV_READY &&
|
|
146
|
+
rPageList[rPrevPageIndex.value].pageReady &&
|
|
147
|
+
rPageList[rCurrentPageIndex.value].pageReady
|
|
148
|
+
) {
|
|
149
|
+
// 抓取界面
|
|
150
|
+
|
|
151
|
+
// 取消上一次的抓取
|
|
152
|
+
vTextureHolder.holder0?.textureRef.cancel();
|
|
153
|
+
vTextureHolder.holder1?.textureRef.cancel();
|
|
154
|
+
|
|
155
|
+
// 抓取当前界面
|
|
156
|
+
rTextureStatus.value = FLIP_STATUS_TAKING;
|
|
157
|
+
|
|
158
|
+
vTextureHolder = {
|
|
159
|
+
holder0: takeTexture(
|
|
160
|
+
rPageList[rPageLives[0]].divRef,
|
|
161
|
+
rPageList[rPageLives[0]].index
|
|
162
|
+
),
|
|
163
|
+
holder1: takeTexture(
|
|
164
|
+
rPageList[rPageLives[1]].divRef,
|
|
165
|
+
rPageList[rPageLives[1]].index
|
|
166
|
+
),
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
let holders = vTextureHolder;
|
|
170
|
+
|
|
171
|
+
// TODO: promise.all的引用和unmount时释放, 可能可以规避组件退出时内存泄露问题
|
|
172
|
+
vTexturePromiseAll = Promise.all([
|
|
173
|
+
holders.holder0.promiseRef,
|
|
174
|
+
holders.holder1.promiseRef,
|
|
175
|
+
])
|
|
176
|
+
.then(([page_0_texture, page_1_texture]) => {
|
|
177
|
+
if (rCurrentPageIndex.value > rPrevPageIndex.value) {
|
|
178
|
+
rTextureNames[0].value = page_0_texture;
|
|
179
|
+
rTextureNames[1].value = page_1_texture;
|
|
180
|
+
} else {
|
|
181
|
+
rTextureNames[0].value = page_1_texture;
|
|
182
|
+
rTextureNames[1].value = page_0_texture;
|
|
183
|
+
}
|
|
184
|
+
rTextureStatus.value = FLIP_STATUS_READY;
|
|
185
|
+
})
|
|
186
|
+
.finally(() => {
|
|
187
|
+
// resolve或者reject时,释放holder引用
|
|
188
|
+
holders.holder0 = null;
|
|
189
|
+
holders.holder1 = null;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
// 暴露组件方法给父组件
|
|
195
|
+
defineExpose({
|
|
196
|
+
/**
|
|
197
|
+
* 设置当前页码
|
|
198
|
+
* @param {number} pageIndex - 要设置的页码索引
|
|
199
|
+
*/
|
|
200
|
+
setCurrentPage: (pageIndex) => {
|
|
201
|
+
if (pageIndex < 0 || pageIndex >= props.pageCount) {
|
|
202
|
+
console.error(`页码超出范围: ${pageIndex}, 总页数: ${props.pageCount}`);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (pageIndex == rCurrentPageIndex.value) {
|
|
207
|
+
// 如果当前页码和要设置的页码相同,则不进行操作
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 更新页码索引
|
|
212
|
+
// 保存旧的当前页码
|
|
213
|
+
const oldCurrentIndex = rCurrentPageIndex.value;
|
|
214
|
+
|
|
215
|
+
if (
|
|
216
|
+
rTextureStatus.value != FLIP_STATUS_IDLE &&
|
|
217
|
+
pageIndex == rPrevPageIndex.value &&
|
|
218
|
+
rPageList[pageIndex].pageReady
|
|
219
|
+
) {
|
|
220
|
+
// 在动画过程中,翻页反向,此时由于页面不重新mount,不会触发fncTriggerFlush
|
|
221
|
+
// 需要手动触发fncTriggerFlush
|
|
222
|
+
Promise.resolve().then(() => {
|
|
223
|
+
fncTriggerFlush(pageIndex);
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// 设置当前页码
|
|
228
|
+
rCurrentPageIndex.value = pageIndex;
|
|
229
|
+
rPrevPageIndex.value = oldCurrentIndex;
|
|
230
|
+
|
|
231
|
+
// 界面进入动画状态
|
|
232
|
+
rTextureStatus.value = FLIP_STATUS_WAIT_DIV_READY;
|
|
233
|
+
|
|
234
|
+
// 设置新页面为未准备就绪
|
|
235
|
+
rPageList[pageIndex].pageReady = false;
|
|
236
|
+
|
|
237
|
+
rPageLives[0] = pageIndex;
|
|
238
|
+
rPageLives[1] = oldCurrentIndex; // 老页面遮挡在上面
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
onMounted(() => {});
|
|
243
|
+
|
|
244
|
+
onUnmounted(() => {
|
|
245
|
+
// 取消截屏处理,并释放promise引用
|
|
246
|
+
vTextureHolder.holder0?.textureRef.cancel();
|
|
247
|
+
vTextureHolder.holder1?.textureRef.cancel();
|
|
248
|
+
vTextureHolder.holder0 = null;
|
|
249
|
+
vTextureHolder.holder1 = null;
|
|
250
|
+
|
|
251
|
+
// 释放PromiseAll引用
|
|
252
|
+
vTexturePromiseAll = null;
|
|
253
|
+
});
|
|
254
|
+
</script>
|
|
255
|
+
|
|
256
|
+
<template>
|
|
257
|
+
<div
|
|
258
|
+
:style="{
|
|
259
|
+
left: props.position.x,
|
|
260
|
+
top: props.position.y,
|
|
261
|
+
}"
|
|
262
|
+
>
|
|
263
|
+
<!-- 通过key锁定, 当 currentPageIndex 变化时,已存在页面不会重新创建 -->
|
|
264
|
+
<div
|
|
265
|
+
v-show="rTextureStatus != FLIP_STATUS_READY"
|
|
266
|
+
v-for="pageIndex in rPageLives"
|
|
267
|
+
:key="pageIndex"
|
|
268
|
+
>
|
|
269
|
+
<div
|
|
270
|
+
v-if="
|
|
271
|
+
pageIndex == rCurrentPageIndex || rTextureStatus != FLIP_STATUS_IDLE
|
|
272
|
+
"
|
|
273
|
+
:ref="(el) => (rPageList[pageIndex].divRef = el)"
|
|
274
|
+
:style="{
|
|
275
|
+
width: props.pageSize.width,
|
|
276
|
+
height: props.pageSize.height,
|
|
277
|
+
}"
|
|
278
|
+
>
|
|
279
|
+
<slot :pageIndex="pageIndex" :triggerFlush="fncTriggerFlush"></slot>
|
|
280
|
+
</div>
|
|
281
|
+
<!-- <div
|
|
282
|
+
:style="{
|
|
283
|
+
width: 300,
|
|
284
|
+
height: 100,
|
|
285
|
+
fontSize: 20,
|
|
286
|
+
color: 'rgba(255,255,255,1)',
|
|
287
|
+
lineHeight: 100,
|
|
288
|
+
}"
|
|
289
|
+
>
|
|
290
|
+
当前界面: {{ "" + pageIndex + " " + rCurrentPageIndex }}
|
|
291
|
+
</div> -->
|
|
292
|
+
</div>
|
|
293
|
+
|
|
294
|
+
<jsv-frag-shader-view
|
|
295
|
+
v-if="rTextureStatus == FLIP_STATUS_READY"
|
|
296
|
+
:style="{
|
|
297
|
+
left: cFlipArea.x,
|
|
298
|
+
top: cFlipArea.y,
|
|
299
|
+
width: cFlipArea.width,
|
|
300
|
+
height: cFlipArea.height,
|
|
301
|
+
}"
|
|
302
|
+
:duration="rPageFlipSettings.duration"
|
|
303
|
+
:shaderStr="rPageFlipSettings.shader"
|
|
304
|
+
:autoplay="true"
|
|
305
|
+
:reverseAnimate="rCurrentPageIndex < rPrevPageIndex"
|
|
306
|
+
:textures="rPageFlipSettings.textures"
|
|
307
|
+
:onEnd="rPageFlipSettings.onEnd"
|
|
308
|
+
></jsv-frag-shader-view>
|
|
309
|
+
</div>
|
|
310
|
+
</template>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
#define PI 3.14159265359
|
|
2
|
+
#define RADIUS .05
|
|
3
|
+
#define LIGHT_DIR vec3(5,3,1)
|
|
4
|
+
#define SPECULAR_SHININESS 24.0
|
|
5
|
+
#define SPECULAR_COLOR vec3(1.0,1.0,1.0)
|
|
6
|
+
#define SPECULAR_POWER 10.0
|
|
7
|
+
//书籍范围的百分比
|
|
8
|
+
#define BOOK_BOUND vec4(0.00, 0.20, 1.00, 1.00)
|
|
9
|
+
|
|
10
|
+
// 优化的快速反正弦函数
|
|
11
|
+
float fastAsin(float x) {
|
|
12
|
+
// 使用更少的项来近似计算
|
|
13
|
+
// return x + (1.0 / 6.0) * x3 + (3.0 / 40.0) * x5 + (5.0 / 112.0) * x7;
|
|
14
|
+
return x + x*x*x*(1.0/6.0) + x*x*x*x*x*(3.0/40.0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 优化的矩形检测函数
|
|
18
|
+
bool inRect(vec2 uv, vec4 rect) {
|
|
19
|
+
return all(greaterThanEqual(uv, rect.xy)) && all(lessThanEqual(uv, rect.zw));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
vec3 fakeSpine(vec3 col, float t, float darken)
|
|
23
|
+
{
|
|
24
|
+
return mix(col * darken, col, min(1.0, sqrt(abs(t) * 30.0)));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
vec3 fakeNormal(float t, float center)
|
|
28
|
+
{
|
|
29
|
+
t -= center;
|
|
30
|
+
float interp = (1.0 - abs(t * 2.0)) * PI + PI * 0.75;
|
|
31
|
+
|
|
32
|
+
vec3 normal = vec3(abs(sin(interp)) ,0. , abs(cos(interp)));
|
|
33
|
+
|
|
34
|
+
return mix(normal, vec3(0.0, 0.0, 1.0), min(1.0, sqrt(abs(t) * 5.0)));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
vec3 specular(vec3 viewDir, vec3 normal)
|
|
38
|
+
{
|
|
39
|
+
vec3 lightDir = normalize(LIGHT_DIR);
|
|
40
|
+
float dist = length(lightDir);
|
|
41
|
+
vec3 halfV = normalize(lightDir + normalize(viewDir));
|
|
42
|
+
|
|
43
|
+
float NdotH = dot(normal, halfV);
|
|
44
|
+
float intensity = pow(max(NdotH, 0.0), SPECULAR_SHININESS);
|
|
45
|
+
|
|
46
|
+
return intensity * SPECULAR_COLOR * SPECULAR_POWER / dist;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
50
|
+
vec2 aspect = iResolution.xy / iResolution.y;
|
|
51
|
+
vec2 uv = fragCoord / iResolution.y;
|
|
52
|
+
// vec2 mouse = iMouse.xy / iResolution.y;
|
|
53
|
+
|
|
54
|
+
vec4 bgColor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
55
|
+
|
|
56
|
+
vec4 viewBounds = vec4(0., 0., aspect);
|
|
57
|
+
vec4 bookBounds = vec4(BOOK_BOUND.xy * aspect, BOOK_BOUND.zw * aspect);
|
|
58
|
+
vec2 bookSize = bookBounds.zw - bookBounds.xy;
|
|
59
|
+
vec2 bookAspect = bookSize.xy / bookSize.y;
|
|
60
|
+
vec4 bookUvBounds = vec4(0.0, 0.0, bookAspect);
|
|
61
|
+
vec2 bookUv = (uv - bookBounds.xy) / bookSize.y;
|
|
62
|
+
// mouse = (mouse - bookBounds.xy) / bookSize.y;
|
|
63
|
+
|
|
64
|
+
// 优化鼠标轨迹计算
|
|
65
|
+
float timeFact = 1. - iTime / iDuration;
|
|
66
|
+
vec2 mouse = vec2(timeFact, 1.2 * timeFact * (timeFact - 1.0) + 1.0) * bookAspect;
|
|
67
|
+
// 防止鼠标超出书本范围
|
|
68
|
+
mouse = clamp(mouse, vec2(0.0), bookAspect - vec2(1e-2));
|
|
69
|
+
|
|
70
|
+
//bookAspect为bookUv的右上角
|
|
71
|
+
vec2 mouseDir = normalize(bookAspect - mouse);
|
|
72
|
+
vec2 origin = mouse - mouseDir * mouse.x / abs(mouseDir.x);
|
|
73
|
+
vec2 axisPos = (mouse + bookAspect) * 0.5; // 使用乘法代替除法
|
|
74
|
+
|
|
75
|
+
float axisDist = length(axisPos - origin);
|
|
76
|
+
|
|
77
|
+
float proj = dot(bookUv - origin, mouseDir);
|
|
78
|
+
float dist = proj - axisDist;
|
|
79
|
+
vec2 linePoint = bookUv - dist * mouseDir;
|
|
80
|
+
|
|
81
|
+
float radius = clamp(2.0 * mouse.x * RADIUS, 0.0, RADIUS);
|
|
82
|
+
|
|
83
|
+
// 提前计算常用值
|
|
84
|
+
bool inBookBounds = inRect(uv, bookBounds);
|
|
85
|
+
|
|
86
|
+
if(dist > radius) {
|
|
87
|
+
if (inRect(uv, bookBounds)) {
|
|
88
|
+
fragColor = jsvTexture2D(iChannel1, bookUv / bookAspect);
|
|
89
|
+
} else {
|
|
90
|
+
fragColor = bgColor;
|
|
91
|
+
}
|
|
92
|
+
} else if(dist >= 0.0) {
|
|
93
|
+
//圆柱体部分
|
|
94
|
+
if (radius > 1e-5) {
|
|
95
|
+
float theta = fastAsin(dist / radius);
|
|
96
|
+
vec2 p1 = linePoint + mouseDir * theta * radius;
|
|
97
|
+
vec2 p2 = linePoint + mouseDir * (PI - theta) * radius;
|
|
98
|
+
|
|
99
|
+
vec2 uv2 = p2 / bookAspect;
|
|
100
|
+
uv2.x = 1.0 - uv2.x;
|
|
101
|
+
|
|
102
|
+
vec2 uv1 = p1 / bookAspect;
|
|
103
|
+
|
|
104
|
+
bool inP2 = inRect(p2, bookUvBounds);
|
|
105
|
+
bool inP1 = inRect(p1, bookUvBounds);
|
|
106
|
+
|
|
107
|
+
if(inP2) {
|
|
108
|
+
fragColor = jsvTexture2D(iChannel1, uv2);
|
|
109
|
+
fragColor.xyz += specular(vec3(0.0, 0.0, 1.0), fakeNormal(dist - radius * 0.5, 0.0)) * 0.2;
|
|
110
|
+
} else if(inP1) {
|
|
111
|
+
fragColor = jsvTexture2D(iChannel0, uv1);
|
|
112
|
+
} else {
|
|
113
|
+
fragColor = bgColor;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
vec2 p = linePoint + mouseDir * (abs(dist) + PI * radius);
|
|
118
|
+
bool inP = inRect(p, bookUvBounds);
|
|
119
|
+
|
|
120
|
+
if (inP) {
|
|
121
|
+
vec2 uv = p / bookAspect;
|
|
122
|
+
uv.x = 1.0 - uv.x;
|
|
123
|
+
fragColor = jsvTexture2D(iChannel1, uv);
|
|
124
|
+
} else if (inRect(bookUv, bookUvBounds) ) {
|
|
125
|
+
vec2 uv2 = bookUv / bookAspect;
|
|
126
|
+
fragColor = jsvTexture2D(iChannel0, uv2);
|
|
127
|
+
} else {
|
|
128
|
+
fragColor = bgColor;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (inBookBounds) {
|
|
133
|
+
fragColor.xyz = fakeSpine(fragColor.xyz, dist - radius, 0.0);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :style="pageStyle">
|
|
3
|
+
<div class="page-number">{{ index }}</div>
|
|
4
|
+
<div
|
|
5
|
+
class="page-detail"
|
|
6
|
+
:style="{
|
|
7
|
+
left: 30,
|
|
8
|
+
top: 30,
|
|
9
|
+
width: pageStyle.width - 60,
|
|
10
|
+
height: pageStyle.height - 60,
|
|
11
|
+
textOverflow: 'ellipsis',
|
|
12
|
+
backgroundColor: 'rgba(0,0,128,0.5)',
|
|
13
|
+
}"
|
|
14
|
+
>
|
|
15
|
+
{{ TextList[index % 3] }}
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script setup>
|
|
21
|
+
import { computed, onUnmounted, onMounted } from "vue";
|
|
22
|
+
|
|
23
|
+
const props = defineProps({
|
|
24
|
+
width: {
|
|
25
|
+
type: Number,
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
height: {
|
|
29
|
+
type: Number,
|
|
30
|
+
required: true,
|
|
31
|
+
},
|
|
32
|
+
index: {
|
|
33
|
+
type: Number,
|
|
34
|
+
required: true,
|
|
35
|
+
},
|
|
36
|
+
flushTrigger: {
|
|
37
|
+
type: Function,
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const TextList = [
|
|
43
|
+
"以下是长句子:\n" +
|
|
44
|
+
"1.石室诗士施氏,嗜狮,誓食十狮。2.施氏时时适市视狮。3.十时,适十狮适市。4.是时,适施氏适市。5.施氏视是十狮,恃矢势,使是十狮逝世。6.氏拾是十狮尸,适石室。7.石室湿,氏使侍拭石室。8.石室拭,施氏始试食是十狮尸。9.食时,始识是十狮尸,实十石狮尸。10.试释是事。\n",
|
|
45
|
+
"以下是长句子:\n" + "君不见,黄河之水天上来,奔流到海不复回。\n",
|
|
46
|
+
"以下是长句子:\n" +
|
|
47
|
+
'ABC انجليزي "abc" سعر الملابس 180 ABC انجليزي "abc" سعر الملابس 180 \n',
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
console.log("页面构建(测试BookFlip用key来保持prevPage)" + props.index);
|
|
51
|
+
|
|
52
|
+
const pageStyle = computed(() => {
|
|
53
|
+
const randomColor = `#${Math.floor(Math.random() * 16777215)
|
|
54
|
+
.toString(16)
|
|
55
|
+
.padStart(6, "0")}`;
|
|
56
|
+
return {
|
|
57
|
+
width: `${props.width}`,
|
|
58
|
+
height: `${props.height}`,
|
|
59
|
+
backgroundColor: randomColor,
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
onMounted(() => {
|
|
64
|
+
console.log("页面挂载(测试BookFlip用key来保持prevPage)" + props.index);
|
|
65
|
+
props.flushTrigger(props.index); // 若有图片,要用jsvPreload进行图片预加载,并在预加载完成后调用flushTrigger
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
onUnmounted(() => {
|
|
69
|
+
console.log("页面销毁(测试BookFlip用key来保持prevPage)" + props.index);
|
|
70
|
+
});
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<style scoped>
|
|
74
|
+
.page-number {
|
|
75
|
+
font-size: 24px;
|
|
76
|
+
color: rgba(255, 255, 255, 1);
|
|
77
|
+
}
|
|
78
|
+
.page-detail {
|
|
79
|
+
font-size: 30px;
|
|
80
|
+
color: rgb(207, 52, 168);
|
|
81
|
+
}
|
|
82
|
+
</style>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :style="{ width: 1280, height: 720, backgroundColor: '#F5F5DC' }"></div>
|
|
3
|
+
<jsv-focus-block autoFocus :onAction="{ onKeyDown }"></jsv-focus-block>
|
|
4
|
+
<div
|
|
5
|
+
:style="{
|
|
6
|
+
width: 1280,
|
|
7
|
+
height: 100,
|
|
8
|
+
lineHeight: 100,
|
|
9
|
+
textAlign: 'center',
|
|
10
|
+
fontSize: 40,
|
|
11
|
+
color: '#000000',
|
|
12
|
+
}"
|
|
13
|
+
>
|
|
14
|
+
按OK键触发动画
|
|
15
|
+
</div>
|
|
16
|
+
<bounce
|
|
17
|
+
ref="bounceRef"
|
|
18
|
+
:src="iLeftSnake"
|
|
19
|
+
:layout="{
|
|
20
|
+
width: 320,
|
|
21
|
+
height: 320,
|
|
22
|
+
top: 400,
|
|
23
|
+
left: 400,
|
|
24
|
+
}"
|
|
25
|
+
/>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script setup>
|
|
29
|
+
import Bounce from "./Bounce.vue";
|
|
30
|
+
import { shallowRef } from "vue";
|
|
31
|
+
|
|
32
|
+
const bounceRef = shallowRef(null);
|
|
33
|
+
let iLeftSnake =
|
|
34
|
+
"https://cdn.release.qcast.cn/JsViewFrameworkTester/JsViewVueSampleResources/DemoForOperator/Bounce/App/snake_left.png?md5=e0310d4ba1c74899899ca365a8b16385";
|
|
35
|
+
|
|
36
|
+
function onKeyDown(ev) {
|
|
37
|
+
if (ev.keyCode == 13) {
|
|
38
|
+
bounceRef.value.start(-400, -400, 7);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<JsvFreeMoveActor
|
|
3
|
+
:top="layout.top"
|
|
4
|
+
:left="layout.left"
|
|
5
|
+
:width="layout.width"
|
|
6
|
+
:height="layout.height"
|
|
7
|
+
ref="actorRef"
|
|
8
|
+
>
|
|
9
|
+
<img
|
|
10
|
+
:src="src"
|
|
11
|
+
:style="{
|
|
12
|
+
width: layout.width,
|
|
13
|
+
height: layout.height,
|
|
14
|
+
}"
|
|
15
|
+
/>
|
|
16
|
+
</JsvFreeMoveActor>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup>
|
|
20
|
+
import { JsvFreeMoveActor } from "jsview";
|
|
21
|
+
import { shallowRef } from "vue";
|
|
22
|
+
import { buildBounce } from "./FreeMoveBuilder";
|
|
23
|
+
|
|
24
|
+
const props = defineProps({
|
|
25
|
+
/**
|
|
26
|
+
* 图片资源路径
|
|
27
|
+
* @type {String}
|
|
28
|
+
* @required
|
|
29
|
+
* @example
|
|
30
|
+
* // 正确用法
|
|
31
|
+
* src: "/images/ball.png"
|
|
32
|
+
*/
|
|
33
|
+
src: {
|
|
34
|
+
type: String,
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 布局配置对象
|
|
40
|
+
* @type {Object}
|
|
41
|
+
* @required
|
|
42
|
+
* @typedef {Object} LayoutConfig
|
|
43
|
+
* @property {number} top - 组件顶部位置(单位:px)
|
|
44
|
+
* @property {number} left - 组件左侧位置(单位:px)
|
|
45
|
+
* @property {number} width - 组件宽度(单位:px)
|
|
46
|
+
* @property {number} height - 组件高度(单位:px)
|
|
47
|
+
* @example
|
|
48
|
+
* // 正确配置示例
|
|
49
|
+
* { top: 100, left: 200, width: 50, height: 50 }
|
|
50
|
+
*/
|
|
51
|
+
layout: {
|
|
52
|
+
type: Object,
|
|
53
|
+
required: true,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
let actorRef = shallowRef(null);
|
|
58
|
+
let vLeftSnakeControl = null;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 启动弹跳动画
|
|
62
|
+
* @param {number} left - 目标位置X坐标(单位:px)
|
|
63
|
+
* @param {number} top - 目标位置Y坐标(单位:px)
|
|
64
|
+
* @param {number} bounceTimes - 弹跳次数(建议1-5次)
|
|
65
|
+
* @description 调用此方法后组件会从当前位置向目标位置执行弹跳动画
|
|
66
|
+
* @example
|
|
67
|
+
* // 在(200,300)位置弹跳3次
|
|
68
|
+
* start(200, 300, 3)
|
|
69
|
+
*/
|
|
70
|
+
function startSnakeAnim(left, top, bounceTimes) {
|
|
71
|
+
vLeftSnakeControl = actorRef.value.control;
|
|
72
|
+
vLeftSnakeControl.run((cmds) => [
|
|
73
|
+
...buildBounce(cmds, 1, left, top, bounceTimes, 2.0, (state) => {}),
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 暴露给父组件的方法
|
|
78
|
+
defineExpose({
|
|
79
|
+
start: startSnakeAnim,
|
|
80
|
+
});
|
|
81
|
+
</script>
|