Yansen 2 年之前
父節點
當前提交
0743d2ef79
共有 2 個檔案被更改,包括 88 行新增3 行删除
  1. 35
    3
      src/components/CustMap.vue
  2. 53
    0
      src/components/ZoomOut.vue

+ 35
- 3
src/components/CustMap.vue 查看文件

23
     <img class="map-border border-bottom" :src="borders[1]" alt=""  @load="onBorderBottomLoad">
23
     <img class="map-border border-bottom" :src="borders[1]" alt=""  @load="onBorderBottomLoad">
24
     <img class="map-border border-left" :src="borders[2]" alt="" :style="borderLRStyle">
24
     <img class="map-border border-left" :src="borders[2]" alt="" :style="borderLRStyle">
25
     <img class="map-border border-right" :src="borders[3]" alt="" :style="borderLRStyle">
25
     <img class="map-border border-right" :src="borders[3]" alt="" :style="borderLRStyle">
26
+    <ZoomOut class="map-zoom-gesture" v-if="showZoomGesture" />
26
   </div>
27
   </div>
27
 </template>
28
 </template>
28
 
29
 
29
 <script setup>
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
   import { useModel } from "@zjxpcyc/vue-tiny-store";
32
   import { useModel } from "@zjxpcyc/vue-tiny-store";
33
   import { newMarker } from '@/utils/amap';
33
   import { newMarker } from '@/utils/amap';
34
   import { resources, borders } from '@/utils/resources';
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
   const props = defineProps({
39
   const props = defineProps({
38
     image: {
40
     image: {
57
   const playing = ref(false);
59
   const playing = ref(false);
58
   const borderTopSize = ref();
60
   const borderTopSize = ref();
59
   const borderBottomSize = ref();
61
   const borderBottomSize = ref();
62
+  const showZoomGesture = ref(true);
60
 
63
 
61
   const isReady = computed(() => imgRef.value && mapIsReady.value);
64
   const isReady = computed(() => imgRef.value && mapIsReady.value);
62
   const borderLRStyle = computed(() => {
65
   const borderLRStyle = computed(() => {
77
   });
80
   });
78
 
81
 
79
   document.body.addEventListener('click', () => {
82
   document.body.addEventListener('click', () => {
83
+    showZoomGesture.value = false;
80
     if (playing.value) {
84
     if (playing.value) {
81
       audioRef.value.toggle();
85
       audioRef.value.toggle();
82
     }
86
     }
108
   }
112
   }
109
 
113
 
110
   const onMapClick = (e) => {
114
   const onMapClick = (e) => {
115
+    showZoomGesture.value = false
111
     const { lnglat } = e;
116
     const { lnglat } = e;
112
 
117
 
113
     // 计算点击位置, 与各景点距离
118
     // 计算点击位置, 与各景点距离
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
 </script>
225
 </script>
201
 
226
 
202
 <style lang="less" scoped>
227
 <style lang="less" scoped>
305
   .border-right {
330
   .border-right {
306
     right: 0;
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
 </style>
342
 </style>

+ 53
- 0
src/components/ZoomOut.vue 查看文件

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>