Yansen 2 anni fa
parent
commit
0743d2ef79
2 ha cambiato i file con 88 aggiunte e 3 eliminazioni
  1. 35
    3
      src/components/CustMap.vue
  2. 53
    0
      src/components/ZoomOut.vue

+ 35
- 3
src/components/CustMap.vue Vedi File

@@ -23,16 +23,18 @@
23 23
     <img class="map-border border-bottom" :src="borders[1]" alt=""  @load="onBorderBottomLoad">
24 24
     <img class="map-border border-left" :src="borders[2]" alt="" :style="borderLRStyle">
25 25
     <img class="map-border border-right" :src="borders[3]" alt="" :style="borderLRStyle">
26
+    <ZoomOut class="map-zoom-gesture" v-if="showZoomGesture" />
26 27
   </div>
27 28
 </template>
28 29
 
29 30
 <script setup>
30
-  import { computed, ref, watch } from "vue";
31
-  import AudioVue from './Audio.vue';
31
+  import { computed, onMounted, ref, watch } from "vue";
32 32
   import { useModel } from "@zjxpcyc/vue-tiny-store";
33 33
   import { newMarker } from '@/utils/amap';
34 34
   import { resources, borders } from '@/utils/resources';
35
-  import wxsdk from "../utils/wx";
35
+  import wxsdk from "@/utils/wx";
36
+  import AudioVue from './Audio.vue';
37
+  import ZoomOut from './ZoomOut.vue';
36 38
 
37 39
   const props = defineProps({
38 40
     image: {
@@ -57,6 +59,7 @@
57 59
   const playing = ref(false);
58 60
   const borderTopSize = ref();
59 61
   const borderBottomSize = ref();
62
+  const showZoomGesture = ref(true);
60 63
 
61 64
   const isReady = computed(() => imgRef.value && mapIsReady.value);
62 65
   const borderLRStyle = computed(() => {
@@ -77,6 +80,7 @@
77 80
   });
78 81
 
79 82
   document.body.addEventListener('click', () => {
83
+    showZoomGesture.value = false;
80 84
     if (playing.value) {
81 85
       audioRef.value.toggle();
82 86
     }
@@ -108,6 +112,7 @@
108 112
   }
109 113
 
110 114
   const onMapClick = (e) => {
115
+    showZoomGesture.value = false
111 116
     const { lnglat } = e;
112 117
 
113 118
     // 计算点击位置, 与各景点距离
@@ -197,6 +202,26 @@
197 202
     })
198 203
   }
199 204
 
205
+  // onMounted(() => {
206
+  //   // 当前地图可见的时候展示放大手势
207
+  //   // 2秒后自动关闭
208
+  //   const observer = new IntersectionObserver((entries) => {
209
+  //     if (entries && entries[0]) {
210
+  //       if (entries[0].intersectionRatio >= 0.6) {
211
+  //         showZoomGesture.value = true;
212
+
213
+  //         const t = setTimeout(() => {
214
+  //           clearTimeout(t);
215
+  //           showZoomGesture.value = false;
216
+  //           observer.disconnect();
217
+  //         }, 2000);
218
+  //       }
219
+  //     }
220
+  //   }, { threshold: [0.6] });
221
+
222
+  //   observer.observe(elRef.value);
223
+  // })
224
+
200 225
 </script>
201 226
 
202 227
 <style lang="less" scoped>
@@ -305,6 +330,13 @@
305 330
   .border-right {
306 331
     right: 0;
307 332
   }
333
+  
334
+  .map-zoom-gesture {
335
+    width: 100px;
336
+    height: 100px;
337
+    left: calc(50% - 25px);
338
+    top: calc(50% - 50px);
339
+  }
308 340
 }
309 341
 
310 342
 </style>

+ 53
- 0
src/components/ZoomOut.vue Vedi File

@@ -0,0 +1,53 @@
1
+<template>
2
+  <div class="room-out-box">
3
+    <i class="iconfont icon-arrow-right"></i>
4
+    <i class="iconfont icon-arrow-right"></i>
5
+  </div>
6
+</template>
7
+
8
+<style lang="less" scoped>
9
+.room-out-box {
10
+  transform: rotate(-45deg);
11
+
12
+  .iconfont {
13
+    font-size: 50px;
14
+    color: #333;
15
+    display: inline-block;
16
+    position: absolute;
17
+    
18
+    &:first-child {
19
+      top: 0;
20
+      right: 0;
21
+      animation: toright 1.2s ease-in-out infinite;
22
+    }
23
+
24
+    &:last-child {
25
+      top: -2px;  // 微调
26
+      left: 0;
27
+      animation: toleft 1.2s ease-in-out infinite;
28
+    }
29
+  }
30
+
31
+  @keyframes toleft {
32
+    from {
33
+      transform: rotate(180deg) translateX(0);
34
+      opacity: 1;
35
+    }
36
+    to {
37
+      transform: rotate(180deg) translateX(20px);
38
+      opacity: 0;
39
+    }
40
+  }
41
+
42
+  @keyframes toright {
43
+    from {
44
+      transform: translateX(0);
45
+      opacity: 1;
46
+    }
47
+    to {
48
+      transform: translateX(20px);
49
+      opacity: 0;
50
+    }
51
+  }
52
+}
53
+</style>