UNPKG

3.44 kBPlain TextView Raw
1<template>
2 <div
3 class="vessel"
4 ref="vessel"
5 :class="{
6 'vessel--rotate': isBackface
7 }"
8 >
9 <editor class="editor"></editor>
10 <monitor class="monitor"></monitor>
11 <div
12 class="flipButton"
13 @click="isBackface = !isBackface"
14 @touchmove.stop="onFlipBtnDrag"
15 :style="{ top: `${flipBtnTop}px` }"
16 >
17 <svg
18 t="1562510307124"
19 class="icon"
20 viewBox="0 0 1024 1024"
21 version="1.1"
22 xmlns="http://www.w3.org/2000/svg"
23 p-id="2037"
24 xmlns:xlink="http://www.w3.org/1999/xlink"
25 >
26 <path
27 d="M213.333333 259.84v512l-55.04-55.466667a42.666667 42.666667 0 0 0-60.586666 60.586667l128 128a42.666667 42.666667 0 0 0 60.586666 0l128-128a42.666667 42.666667 0 0 0 0-60.586667 42.666667 42.666667 0 0 0-60.586666 0L298.666667 771.84v-512A66.56 66.56 0 0 1 363.946667 192H469.333333a42.666667 42.666667 0 0 0 0-85.333333H363.946667A151.893333 151.893333 0 0 0 213.333333 259.84zM609.706667 247.04a42.666667 42.666667 0 0 0 60.586666 60.586667L725.333333 252.16v512a66.56 66.56 0 0 1-65.28 67.84H554.666667a42.666667 42.666667 0 0 0 0 85.333333h105.386666A151.893333 151.893333 0 0 0 810.666667 764.16v-512l55.04 55.466667a42.666667 42.666667 0 0 0 60.586666 0 42.666667 42.666667 0 0 0 0-60.586667l-128-128a42.666667 42.666667 0 0 0-60.586666 0z"
28 p-id="2038"
29 ></path>
30 </svg>
31 </div>
32 </div>
33</template>
34
35<script>
36import Editor from '@/components/editor.vue';
37import Monitor from '@/components/monitor.vue';
38export default {
39 name: 'vessel',
40 data() {
41 return {
42 isBackface: false,
43 flipBtnTop: 200
44 };
45 },
46 components: {
47 Editor,
48 Monitor
49 },
50 methods: {
51 // 翻页按钮
52 onFlipBtnDrag(e) {
53 let top = e.targetTouches[0].clientY;
54 top = Math.min(window.screen.height - 40, Math.max(0, top));
55 this.flipBtnTop = top;
56 }
57 }
58};
59</script>
60
61<style lang="scss">
62@import '@/css/index.scss';
63.vessel {
64 display: grid;
65 grid-template-columns: repeat(2, 1fr);
66 grid-gap: 1px;
67 & .editor {
68 background: $c-bg;
69 }
70 & .monitor {
71 background: $c-bg;
72 }
73 & .flipButton {
74 display: none;
75 }
76}
77
78@media (max-width: $c-small-screen) {
79 .vessel {
80 position: relative;
81 display: block;
82 & .editor,
83 .monitor {
84 position: absolute;
85 top: 0;
86 left: 0;
87 width: 100%;
88 backface-visibility: hidden;
89 transition: 1s all ease;
90 border: 1px solid $c-gap;
91 }
92 & .monitor {
93 height: 100%;
94 transform: perspective(800px) rotateY(0deg);
95 }
96 & .editor {
97 transform: perspective(800px) rotateY(180deg);
98 }
99 &--rotate {
100 & .editor {
101 transform: perspective(800px) rotateY(0deg);
102 }
103 & .monitor {
104 transform: perspective(800px) rotateY(-180deg);
105 & #monitor-iframe {
106 opacity: 0;
107 }
108 }
109 }
110 & .flipButton {
111 display: block;
112 position: fixed;
113 top: 50%;
114 left: 0;
115 border-radius: 0 50% 50% 0;
116 width: 35px;
117 height: 30px;
118 display: flex;
119 justify-content: flex-end;
120 align-items: center;
121 background: $c-flipbtn-bg;
122 opacity: 0.4;
123 transition: opacity 0.2s ease-out;
124 & svg {
125 width: 20px;
126 height: 20px;
127 margin-right: 5px;
128 fill: $c-flipbtn-color;
129 }
130 &:active {
131 opacity: 1;
132 }
133 }
134 }
135}
136</style>