@shijiu/jsview-vue-samples 2.2.201 → 2.2.373
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/App.vue +6 -1
- package/Basic/components/anim/AnimEasingCubicBezier.vue +56 -0
- package/Basic/components/anim/AnimGroup2.vue +33 -0
- package/Basic/components/panel/Panel2.vue +8 -3
- package/CoupletsTest/widget/Banger/Maroon.vue +0 -1
- package/CoupletsTest/widget/Fireworks/Fireworks.vue +0 -2
- package/CustomShader/App.vue +30 -13
- package/CustomShader/pageFlip.glsl +3 -2
- package/DemoHomepage/App.vue +14 -5
- package/DemoHomepage/components/Item.vue +23 -12
- package/DemoHomepage/index.d.ts +5 -2
- package/DemoHomepage/router.js +97 -74
- package/DispersedFocusControl/App.vue +67 -0
- package/DispersedFocusControl/Button.vue +76 -0
- package/DispersedFocusControl/data.js +44 -0
- package/DragBox/App.vue +148 -0
- package/FlexCellDemo/App.vue +47 -223
- package/FlexCellDemo/TestFrame1.vue +88 -0
- package/FlexCellDemo/TestFrame2.vue +100 -0
- package/FlexCellDemo/TestFrame3.vue +97 -0
- package/FlexCellDemo/TestFrame4.vue +60 -0
- package/FlexCellDemo/TestFrame5.vue +60 -0
- package/FlexCellDemo/images/6.jpg +0 -0
- package/FocusMoveStyle/App.vue +1 -0
- package/FocusMoveStyle/CreepFocus.vue +11 -1
- package/FocusMoveStyle/FoldableItem.vue +1 -1
- package/FullScreenFlex/App.vue +42 -0
- package/FullScreenFlex/TestFrame2.vue +107 -0
- package/FullScreenFlex/images/1.png +0 -0
- package/HashHistory/App.vue +8 -4
- package/Input/App.vue +184 -97
- package/Input/InputPanel.vue +98 -82
- package/LatexFormula/App.vue +97 -10
- package/MetroWidgetDemos/itemSizeUpdate/backward/Item.vue +1 -1
- package/MetroWidgetDemos/routeList.js +17 -17
- package/MindMap/App.vue +10 -1
- package/MindMap/data.js +34 -8
- package/Parkour/appConfig/jsview.config.mjs +0 -4
- package/PosterPacker/App.vue +207 -0
- package/PosterPacker/images/bg.jpg +0 -0
- package/PosterPacker/images/blue.png +0 -0
- package/PosterPacker/images/darkGreen.png +0 -0
- package/PosterPacker/images/left.png +0 -0
- package/PosterPacker/images/orange.png +0 -0
- package/PosterPacker/images/pink.png +0 -0
- package/PosterPacker/images/purple.png +0 -0
- package/PosterPacker/images/red.png +0 -0
- package/PosterPacker/images/right.png +0 -0
- package/PosterPacker/images/yellowGreen.png +0 -0
- package/PosterPacker/tools/geniePakcer/Genie.vue +686 -0
- package/PosterPacker/tools/geniePakcer/genieBottom.glsl +49 -0
- package/PosterPacker/tools/geniePakcer/genieLeft.glsl +50 -0
- package/PosterPacker/tools/geniePakcer/genieRight.glsl +57 -0
- package/PosterPacker/tools/geniePakcer/genieTop.glsl +50 -0
- package/PosterPacker/tools/particlePacker/Particle.vue +71 -0
- package/PosterPacker/tools/vortexPacker/Vortex.vue +135 -0
- package/PosterPacker/tools/vortexPacker/vortex.glsl +37 -0
- package/Preload/App.vue +1 -1
- package/ScrollBoxTest/ClipBar.vue +1 -0
- package/ScrollBoxTest/NinePatchBar.vue +1 -0
- package/ScrollBoxTest/SizeDivBar.vue +1 -0
- package/SprayMove/App.vue +75 -0
- package/SprayMove/SprayMove.vue +173 -0
- package/SprayView/App.vue +8 -9
- package/TestNativeSharedView/App.vue +6 -4
- package/TextShadowDemo/App.vue +3 -3
- package/TextureAnimation/App.vue +244 -148
- package/TextureAnimation/App2.vue +66 -14
- package/TextureAnimation/assets/blackWhiteTurntable.png +0 -0
- package/TextureAnimation/assets/circleHaloMask.png +0 -0
- package/TouchWidget/App.vue +79 -40
- package/TouchWidget/Item.vue +15 -3
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/TextureAnimation/assets/mask.png +0 -0
- package/TextureAnimation/assets/php.jpg +0 -0
- package/TouchSample/App.vue +0 -136
- package/TouchSample/Item.vue +0 -102
- package/TouchSample/MetroWidgetHorizontal.vue +0 -144
- package/TouchSample/MetroWidgetVertical.vue +0 -144
- package/TouchSample/TouchContainerHorizontal.vue +0 -160
- package/TouchSample/TouchContainerVertical.vue +0 -160
- package/TouchSample/data.js +0 -81
- /package/TextureAnimation/assets/{php2.png → borderOpacity.png} +0 -0
package/BakeViewDemo/App.vue
CHANGED
|
@@ -37,7 +37,12 @@ onMounted(() => {
|
|
|
37
37
|
(textureName, autoRecycle, w, h) => {
|
|
38
38
|
vCapturedTexture.value = textureName;
|
|
39
39
|
console.log(`capture done id=${textureName} w=${w} h=${h}`);
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
if (autoRecycle) {
|
|
42
|
+
// 已经是设置了texture的自动回收,所以不再需要主动调用 JsvTextureStoreApi.deleteTexture 来释放内存
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
true // 自动回收, 不填也行,默认为true
|
|
41
46
|
);
|
|
42
47
|
}, 2200);
|
|
43
48
|
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { getKeyFramesGroup } from "jsview";
|
|
3
|
+
import { onBeforeUnmount } from "vue";
|
|
4
|
+
|
|
5
|
+
const itemStyle = {
|
|
6
|
+
top: 20,
|
|
7
|
+
left: 20,
|
|
8
|
+
width: 60,
|
|
9
|
+
height: 60,
|
|
10
|
+
fontSize: 15,
|
|
11
|
+
color: "rgba(255, 255, 0, 1)",
|
|
12
|
+
backgroundColor: "rgba(255, 0, 0, 1)",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// 单纯的放大动画使用贝塞尔的timingFunction成为心跳效果
|
|
16
|
+
const cP1 = [0.42, 3.96];
|
|
17
|
+
const cP2 = [0.62, 0];
|
|
18
|
+
const sScaleUpTs = `BasicAnim_PumpUp 0.8s cubic-bezier(${cP1[0]}, ${cP1[1]}, ${cP2[0]}, ${cP2[1]}) infinite`;
|
|
19
|
+
|
|
20
|
+
// 暂时不暴露fill-mode = forwards接口
|
|
21
|
+
// const sScaleUpOnce = `BasicAnim_PumpUp 0.8s cubic-bezier(${cP1[0]}, ${cP1[1]}, ${cP2[0]}, ${cP2[1]}) 3 forwards`;
|
|
22
|
+
|
|
23
|
+
// 拿取group句柄
|
|
24
|
+
const styleShell = getKeyFramesGroup();
|
|
25
|
+
|
|
26
|
+
// 动态注入规则, 注意 keyFrame 名称是全局的, 不要重名
|
|
27
|
+
styleShell.insertRule(
|
|
28
|
+
"@keyframes BasicAnim_PumpUp \
|
|
29
|
+
{from {transform: scale3d(1, 1, 1);} \
|
|
30
|
+
to {transform: scale3d(1.2, 1.2, 1);}}"
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// keyFrame 注意unmount时的销毁
|
|
34
|
+
onBeforeUnmount(() => {
|
|
35
|
+
styleShell.removeRule("BasicAnim_PumpUp");
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<template>
|
|
40
|
+
<div id="layout-root">
|
|
41
|
+
<div :style="{ ...itemStyle, animation: sScaleUpTs }">
|
|
42
|
+
{{ "心跳\n效果" }}
|
|
43
|
+
</div>
|
|
44
|
+
<!-- <div
|
|
45
|
+
:style="{
|
|
46
|
+
...itemStyle,
|
|
47
|
+
left: 100,
|
|
48
|
+
animation: sScaleUpOnce,
|
|
49
|
+
}"
|
|
50
|
+
>
|
|
51
|
+
{{ "心跳\n效果2" }}
|
|
52
|
+
</div> -->
|
|
53
|
+
</div>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<style></style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { reactive, onMounted, onBeforeUnmount } from "vue";
|
|
3
|
+
import ContentBlock from "../ContentBlock.vue";
|
|
4
|
+
import AnimEasingCubicBezier from "./AnimEasingCubicBezier.vue";
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
contentClass: String,
|
|
8
|
+
itemSides: Object,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const contentBlockProps = {
|
|
12
|
+
colIndex: 0,
|
|
13
|
+
itemSides: props.itemSides,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
onMounted(() => {});
|
|
17
|
+
|
|
18
|
+
onBeforeUnmount(() => {});
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<div id="item-root">
|
|
23
|
+
<ContentBlock
|
|
24
|
+
:class="contentClass"
|
|
25
|
+
:style="{ top: itemSides.height * 0 }"
|
|
26
|
+
:="contentBlockProps"
|
|
27
|
+
:index="1"
|
|
28
|
+
title="贝塞尔动画"
|
|
29
|
+
>
|
|
30
|
+
<AnimEasingCubicBezier />
|
|
31
|
+
</ContentBlock>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import TitleBar from "./TitleBar.vue";
|
|
3
3
|
import ImageGroup from "../img/ImageGroup.vue";
|
|
4
|
+
import AnimGroup2 from "../anim/AnimGroup2.vue";
|
|
4
5
|
|
|
5
6
|
const props = defineProps({
|
|
6
7
|
panelClass: String,
|
|
7
8
|
itemSides: Object,
|
|
8
9
|
});
|
|
9
10
|
|
|
10
|
-
const titleData = ["img标签"];
|
|
11
|
+
const titleData = ["img标签", "div动画2"];
|
|
11
12
|
</script>
|
|
12
13
|
|
|
13
14
|
<template>
|
|
@@ -23,9 +24,13 @@ const titleData = ["img标签"];
|
|
|
23
24
|
:contentClass="panelClass"
|
|
24
25
|
:itemSides="itemSides"
|
|
25
26
|
/>
|
|
27
|
+
<AnimGroup2
|
|
28
|
+
:style="{ left: itemSides.width * 1 }"
|
|
29
|
+
:contentClass="panelClass"
|
|
30
|
+
:itemSides="itemSides"
|
|
31
|
+
/>
|
|
26
32
|
</div>
|
|
27
33
|
</div>
|
|
28
34
|
</template>
|
|
29
35
|
|
|
30
|
-
<style>
|
|
31
|
-
</style>
|
|
36
|
+
<style></style>
|
|
@@ -270,7 +270,6 @@ const sprayOk = {
|
|
|
270
270
|
lifeMax: 800,
|
|
271
271
|
accelerateX: 0,
|
|
272
272
|
accelerateY: 0,
|
|
273
|
-
addNumSpeed: 0.001,
|
|
274
273
|
enableFade: false,
|
|
275
274
|
enableShrink: true,
|
|
276
275
|
};
|
|
@@ -288,7 +287,6 @@ const sprayOk1 = {
|
|
|
288
287
|
lifeMax: 2000,
|
|
289
288
|
accelerateX: 0,
|
|
290
289
|
accelerateY: -40,
|
|
291
|
-
addNumSpeed: 0.001,
|
|
292
290
|
enableFade: false,
|
|
293
291
|
enableShrink: false,
|
|
294
292
|
};
|
package/CustomShader/App.vue
CHANGED
|
@@ -24,6 +24,7 @@ const cShaderSettings = [
|
|
|
24
24
|
resource: ImageOwl,
|
|
25
25
|
},
|
|
26
26
|
],
|
|
27
|
+
duration: 100000,
|
|
27
28
|
},
|
|
28
29
|
{
|
|
29
30
|
name: "pageFlip",
|
|
@@ -35,6 +36,16 @@ const cShaderSettings = [
|
|
|
35
36
|
resource: ImageOwl,
|
|
36
37
|
},
|
|
37
38
|
],
|
|
39
|
+
duration: 500,
|
|
40
|
+
onEnd: (id, status) => {
|
|
41
|
+
if (status) {
|
|
42
|
+
// 动画正常结束,而非cancel打断
|
|
43
|
+
console.log("flip anim end");
|
|
44
|
+
rShowShaderView.value = false;
|
|
45
|
+
} else {
|
|
46
|
+
console.log("flip anim cancel");
|
|
47
|
+
}
|
|
48
|
+
},
|
|
38
49
|
},
|
|
39
50
|
{
|
|
40
51
|
name: "sdf",
|
|
@@ -46,7 +57,9 @@ const cShaderSettings = [
|
|
|
46
57
|
resource: ImageOwl,
|
|
47
58
|
},
|
|
48
59
|
],
|
|
60
|
+
duration: 100000,
|
|
49
61
|
},
|
|
62
|
+
// 高斯模糊性能太差,先不做推广
|
|
50
63
|
{
|
|
51
64
|
name: "gaussianBlur",
|
|
52
65
|
shader: gaussianBlurShader,
|
|
@@ -57,27 +70,31 @@ const cShaderSettings = [
|
|
|
57
70
|
resource: ImageOwl,
|
|
58
71
|
},
|
|
59
72
|
],
|
|
73
|
+
duration: 0,
|
|
60
74
|
},
|
|
61
75
|
];
|
|
62
76
|
|
|
77
|
+
const rShowShaderView = ref(true);
|
|
63
78
|
const rKeyCount = ref(0);
|
|
64
79
|
const rShaderInfo = computed(() => {
|
|
65
80
|
return cShaderSettings[rKeyCount.value];
|
|
66
81
|
});
|
|
67
82
|
|
|
68
83
|
const rAutoplay = computed(() => {
|
|
69
|
-
return
|
|
84
|
+
return true;
|
|
70
85
|
});
|
|
71
86
|
|
|
72
87
|
const rWidgetRef = ref();
|
|
73
88
|
const onKeyDown = (ev) => {
|
|
74
89
|
switch (ev.keyCode) {
|
|
75
90
|
case 37: {
|
|
91
|
+
rShowShaderView.value = true;
|
|
76
92
|
rKeyCount.value =
|
|
77
93
|
rKeyCount.value > 0 ? rKeyCount.value - 1 : rKeyCount.value;
|
|
78
94
|
return true;
|
|
79
95
|
}
|
|
80
96
|
case 39: {
|
|
97
|
+
rShowShaderView.value = true;
|
|
81
98
|
rKeyCount.value =
|
|
82
99
|
rKeyCount.value < cShaderSettings.length - 1
|
|
83
100
|
? rKeyCount.value + 1
|
|
@@ -85,9 +102,8 @@ const onKeyDown = (ev) => {
|
|
|
85
102
|
return true;
|
|
86
103
|
}
|
|
87
104
|
case 13: {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
105
|
+
rShowShaderView.value = true;
|
|
106
|
+
rWidgetRef.value?.startAnim();
|
|
91
107
|
return true;
|
|
92
108
|
}
|
|
93
109
|
default:
|
|
@@ -111,30 +127,31 @@ onUnmounted(() => {
|
|
|
111
127
|
onKeyDown,
|
|
112
128
|
}"
|
|
113
129
|
:style="{
|
|
114
|
-
width:
|
|
115
|
-
height:
|
|
130
|
+
width: 1280,
|
|
131
|
+
height: 720,
|
|
116
132
|
backgroundImage: `url(${ImageChinChilla})`,
|
|
117
133
|
}"
|
|
118
134
|
></jsv-focus-block>
|
|
119
135
|
|
|
120
136
|
<jsv-frag-shader-view
|
|
137
|
+
v-if="rShowShaderView"
|
|
121
138
|
:key="rKeyCount"
|
|
122
139
|
ref="rWidgetRef"
|
|
123
|
-
:style="{ left: 0, top: 0, width:
|
|
124
|
-
:duration="
|
|
140
|
+
:style="{ left: 0, top: 0, width: 1280, height: 720 }"
|
|
141
|
+
:duration="rShaderInfo.duration"
|
|
125
142
|
:shaderStr="rShaderInfo.shader"
|
|
126
143
|
:autoplay="rAutoplay"
|
|
127
144
|
:textures="rShaderInfo.textures"
|
|
145
|
+
:onEnd="rShaderInfo.onEnd"
|
|
128
146
|
></jsv-frag-shader-view>
|
|
129
147
|
<div
|
|
130
148
|
:key="rKeyCount"
|
|
131
149
|
:style="{
|
|
132
|
-
top:
|
|
133
|
-
left:
|
|
150
|
+
top: 100,
|
|
151
|
+
left: 20,
|
|
134
152
|
width: 500,
|
|
135
153
|
height: 50,
|
|
136
154
|
fontSize: 30,
|
|
137
|
-
textAlign: 'center',
|
|
138
155
|
backgroundColor: '#00000055',
|
|
139
156
|
color: '#ffffff',
|
|
140
157
|
}"
|
|
@@ -143,8 +160,8 @@ onUnmounted(() => {
|
|
|
143
160
|
</div>
|
|
144
161
|
<div
|
|
145
162
|
:style="{
|
|
146
|
-
top:
|
|
147
|
-
left:
|
|
163
|
+
top: 150,
|
|
164
|
+
left: 20,
|
|
148
165
|
width: 500,
|
|
149
166
|
height: 50,
|
|
150
167
|
fontSize: 30,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//https://andrewhungblog.wordpress.com/2018/04/29/page-curl-shader-breakdown/
|
|
1
2
|
#define pi 3.14159265359
|
|
2
3
|
#define radius .1
|
|
3
4
|
|
|
@@ -13,7 +14,7 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
|
13
14
|
vec2 aspect = iResolution.xy / iResolution.y;
|
|
14
15
|
vec2 uv = fragCoord * aspect / iResolution.xy;
|
|
15
16
|
vec2 anchor = aspect;
|
|
16
|
-
vec2 mouse = anchor - abs(
|
|
17
|
+
vec2 mouse = anchor - abs(iTime / iDuration) * anchor;
|
|
17
18
|
vec2 mouseDir = normalize(anchor - mouse);
|
|
18
19
|
vec2 origin = mouse - mouseDir * mouse.x / abs(mouseDir.x);
|
|
19
20
|
float mouseDist = length(mouse - origin);
|
|
@@ -22,7 +23,7 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
|
22
23
|
float dist = proj - mouseDist;
|
|
23
24
|
vec2 linePoint = uv - dist * mouseDir;
|
|
24
25
|
if(dist > radius) {
|
|
25
|
-
fragColor = vec4(0.0, 0.
|
|
26
|
+
fragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
26
27
|
fragColor.rgb *= pow(clamp(dist - radius, 0., 1.) * 1.5, .2);
|
|
27
28
|
} else if(dist >= 0.) {
|
|
28
29
|
// map to cylinder point
|
package/DemoHomepage/App.vue
CHANGED
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
* @Description: file content
|
|
7
7
|
-->
|
|
8
8
|
<script setup>
|
|
9
|
-
import { shallowRef, onMounted, onUnmounted } from "vue";
|
|
9
|
+
import { shallowRef, onMounted, onUnmounted, provide } from "vue";
|
|
10
10
|
import {
|
|
11
11
|
JsvPreload,
|
|
12
12
|
buildPreloadInfo,
|
|
13
13
|
jJsvRuntimeBridge,
|
|
14
14
|
JsvFocusBlock,
|
|
15
15
|
useFocusHub,
|
|
16
|
+
JsvTouchModeSwitcher,
|
|
16
17
|
} from "jsview";
|
|
17
18
|
import { useRouter } from "vue-router";
|
|
18
19
|
import { setDataUrl, getDataUrl } from "../CommonUtils/ResourceData.js";
|
|
@@ -20,7 +21,8 @@ import { getSearchQuery } from "../CommonUtils/getSearchQuery.js";
|
|
|
20
21
|
|
|
21
22
|
let DemoResourceBase = shallowRef("");
|
|
22
23
|
let backgroundImageUrl = shallowRef(null);
|
|
23
|
-
|
|
24
|
+
const touchModeSwitcherRef = shallowRef();
|
|
25
|
+
provide("touchModeSwitcherRef", touchModeSwitcherRef);
|
|
24
26
|
// let preloadInfo = shallowRef([]);
|
|
25
27
|
|
|
26
28
|
window.DebugFocusHub = useFocusHub();
|
|
@@ -54,6 +56,9 @@ if (query.DemoResourceBase) {
|
|
|
54
56
|
DemoResourceBase.value = getDataUrl();
|
|
55
57
|
}
|
|
56
58
|
onMounted(() => {
|
|
59
|
+
touchModeSwitcherRef.value?.registerCallback((mode) => {
|
|
60
|
+
console.log("change mode to", mode == 1 ? "key" : "touch");
|
|
61
|
+
});
|
|
57
62
|
console.log("simulate async get background url");
|
|
58
63
|
setTimeout(() => {
|
|
59
64
|
console.log("simulate background url got");
|
|
@@ -79,7 +84,11 @@ onUnmounted(() => {
|
|
|
79
84
|
</script>
|
|
80
85
|
|
|
81
86
|
<template>
|
|
82
|
-
<
|
|
87
|
+
<jsv-touch-mode-switcher
|
|
88
|
+
ref="touchModeSwitcherRef"
|
|
89
|
+
:width="1280"
|
|
90
|
+
:height="720"
|
|
91
|
+
>
|
|
83
92
|
<!-- <jsv-preload :key="backgroundImageUrl" :preloadList="preloadInfo" :onPreloadDone="_onPreloadDone" /> -->
|
|
84
93
|
<img
|
|
85
94
|
:src="backgroundImageUrl"
|
|
@@ -90,7 +99,7 @@ onUnmounted(() => {
|
|
|
90
99
|
@load="_onPreloadDone"
|
|
91
100
|
/>
|
|
92
101
|
<div class="TestKeepAliveDiv">
|
|
93
|
-
{{ "
|
|
102
|
+
{{ "更新页面计数:" + testKeepAliveModeText }}
|
|
94
103
|
</div>
|
|
95
104
|
<jsv-focus-block
|
|
96
105
|
:onAction="{
|
|
@@ -104,7 +113,7 @@ onUnmounted(() => {
|
|
|
104
113
|
<component v-if="!route.meta.keepAlive" :is="Component" />
|
|
105
114
|
</router-view>
|
|
106
115
|
</jsv-focus-block>
|
|
107
|
-
</
|
|
116
|
+
</jsv-touch-mode-switcher>
|
|
108
117
|
</template>
|
|
109
118
|
|
|
110
119
|
<style scoped>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { shallowRef, computed } from "vue"
|
|
2
|
+
import { shallowRef, computed, inject } from "vue";
|
|
3
3
|
const props = defineProps({
|
|
4
4
|
style: Object,
|
|
5
5
|
itemClick: Function,
|
|
@@ -7,16 +7,17 @@ const props = defineProps({
|
|
|
7
7
|
data: Object,
|
|
8
8
|
query: Object,
|
|
9
9
|
onAction: Object,
|
|
10
|
-
})
|
|
10
|
+
});
|
|
11
11
|
|
|
12
|
-
let focused = shallowRef(false)
|
|
12
|
+
let focused = shallowRef(false);
|
|
13
|
+
const touchModeSwitcherRef = inject("touchModeSwitcherRef");
|
|
13
14
|
|
|
14
15
|
const foucsStyle = computed(() => {
|
|
15
16
|
return {
|
|
16
17
|
width: props.style.width,
|
|
17
18
|
height: props.style.height,
|
|
18
19
|
};
|
|
19
|
-
})
|
|
20
|
+
});
|
|
20
21
|
|
|
21
22
|
const itemStyle = computed(() => {
|
|
22
23
|
return {
|
|
@@ -25,31 +26,41 @@ const itemStyle = computed(() => {
|
|
|
25
26
|
backgroundColor: props.style.backgroundColor,
|
|
26
27
|
color: props.style.color,
|
|
27
28
|
};
|
|
29
|
+
});
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
const modeChangeCallback = (mode) => {
|
|
32
|
+
if (mode == 2) {
|
|
33
|
+
focused.value = false;
|
|
34
|
+
} else {
|
|
35
|
+
focused.value = true;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
30
38
|
|
|
31
39
|
const onFocus = () => {
|
|
32
|
-
|
|
40
|
+
//为了避免每个item都注册回调, 这里onFocus时注册, onBlur时注销
|
|
41
|
+
touchModeSwitcherRef.value.registerCallback(modeChangeCallback);
|
|
42
|
+
if (touchModeSwitcherRef.value.getInteractiveMode() == 1) {
|
|
43
|
+
focused.value = true;
|
|
44
|
+
}
|
|
33
45
|
if (props.itemFocus) {
|
|
34
46
|
props.itemFocus(props.data);
|
|
35
47
|
}
|
|
36
|
-
}
|
|
48
|
+
};
|
|
37
49
|
|
|
38
50
|
const onBlur = () => {
|
|
51
|
+
touchModeSwitcherRef.value.unregisterCallback(modeChangeCallback);
|
|
39
52
|
focused.value = false;
|
|
40
|
-
}
|
|
53
|
+
};
|
|
41
54
|
|
|
42
55
|
const onClick = () => {
|
|
43
|
-
console.log("testtest", "onclick ", props.data.name)
|
|
44
56
|
if (props.itemClick) {
|
|
45
57
|
props?.itemClick(props.query.id, props.data);
|
|
46
58
|
}
|
|
47
|
-
}
|
|
59
|
+
};
|
|
48
60
|
|
|
49
61
|
props.onAction.register("onFocus", onFocus);
|
|
50
62
|
props.onAction.register("onBlur", onBlur);
|
|
51
63
|
props.onAction.register("onClick", onClick);
|
|
52
|
-
|
|
53
64
|
</script>
|
|
54
65
|
|
|
55
66
|
<template>
|
|
@@ -72,4 +83,4 @@ props.onAction.register("onClick", onClick);
|
|
|
72
83
|
text-align: center;
|
|
73
84
|
font-size: 30;
|
|
74
85
|
}
|
|
75
|
-
</style>
|
|
86
|
+
</style>
|