fix: the lost animation (#175)

- 恢复移除的 css 代码,并将其并入 `<Loading>` 组件当中
- 动画控制迁移至 `<Loading>`
This commit is contained in:
YangQi 2022-08-08 17:30:41 +08:00 committed by GitHub
parent dd4fe6f3cf
commit 7ea21044b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 39 deletions

View File

@ -1,23 +1,32 @@
<template> <template>
<div class="loading" id="loading"> <transition name="fade" v-if="loading">
<div class="loading-wrapper"> <div class="loading">
<div class="loading-anim"></div> <div class="loading-wrapper">
<div class="loading-text">致力于让 Markdown 编辑更简单</div> <div class="loading-anim"></div>
<div class="loading-text">致力于让 Markdown 编辑更简单</div>
</div>
</div> </div>
</div> </transition>
</template> </template>
<script></script> <script>
export default {
name: `Loading`,
data() {
return {
loading: true,
}
},
mounted() {
setTimeout(() => {
this.loading = false
}, 100)
},
}
</script>
<style lang="less" scoped> <style lang="less" scoped>
.loading-wrapper {
position: fixed;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
}
.loading { .loading {
text-align: center;
position: fixed; position: fixed;
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -30,11 +39,12 @@
background-color: #303133; background-color: #303133;
} }
.loading-text { .loading-wrapper {
font-size: 18px; position: absolute;
font-weight: bold; top: 50%;
margin-top: 26px; left: 50%;
color: #303133; transform: translateX(-50%) translateY(-50%);
text-align: center;
} }
.loading-anim { .loading-anim {
@ -44,4 +54,26 @@
background: url('../assets/images/favicon.png') no-repeat; background: url('../assets/images/favicon.png') no-repeat;
background-size: cover; background-size: cover;
} }
.loading-text {
font-size: 18px;
font-weight: bold;
margin-top: 26px;
color: #303133;
}
.fade-enter,
.fade-leave-to {
opacity: 0;
}
.fade-enter-to,
.fade-leave {
opacity: 1;
}
.fade-enter-active,
.fade-leave-active {
transition: opacity 1s;
}
</style> </style>

View File

@ -100,14 +100,16 @@
@menuTick="onMenuEvent" @menuTick="onMenuEvent"
@closeMenu="closeRightClickMenu" @closeMenu="closeRightClickMenu"
/> />
<loading></loading>
</div> </div>
</template> </template>
<script> <script>
import editorHeader from '../components/CodemirrorEditor/header' import editorHeader from '@/components/CodemirrorEditor/header'
import aboutDialog from '../components/CodemirrorEditor/aboutDialog' import aboutDialog from '@/components/CodemirrorEditor/aboutDialog'
import insertFormDialog from '../components/CodemirrorEditor/insertForm' import insertFormDialog from '@/components/CodemirrorEditor/insertForm'
import rightClickMenu from '../components/CodemirrorEditor/rightClickMenu' import rightClickMenu from '@/components/CodemirrorEditor/rightClickMenu'
import uploadImgDialog from '../components/CodemirrorEditor/uploadImgDialog' import uploadImgDialog from '@/components/CodemirrorEditor/uploadImgDialog'
import Loading from '@/components/Loading'
import { import {
css2json, css2json,
@ -143,6 +145,7 @@ export default {
} }
}, },
components: { components: {
Loading,
editorHeader, editorHeader,
aboutDialog, aboutDialog,
insertFormDialog, insertFormDialog,
@ -710,20 +713,25 @@ export default {
100% { 100% {
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1); transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
} }
0% { 0% {
opacity: 0; opacity: 0;
transform: translate3d(3000px, 0, 0); transform: translate3d(3000px, 0, 0);
} }
60% { 60% {
opacity: 1; opacity: 1;
transform: translate3d(-25px, 0, 0); transform: translate3d(-25px, 0, 0);
} }
75% { 75% {
transform: translate3d(10px, 0, 0); transform: translate3d(10px, 0, 0);
} }
90% { 90% {
transform: translate3d(-5px, 0, 0); transform: translate3d(-5px, 0, 0);
} }
100% { 100% {
transform: none; transform: none;
} }
@ -733,6 +741,7 @@ export default {
overflow-x: auto; overflow-x: auto;
} }
</style> </style>
<style lang="less" scoped> <style lang="less" scoped>
@import url('../assets/less/app.less'); @import url('../assets/less/app.less');
</style> </style>

View File

@ -1,30 +1,15 @@
<template> <template>
<transition name="fade" v-if="loading"> <codemirror-editor />
<loading />
</transition>
<codemirror-editor v-else />
</template> </template>
<script> <script>
import Loading from '../components/Loading'
import CodemirrorEditor from './CodemirrorEditor' import CodemirrorEditor from './CodemirrorEditor'
export default { export default {
name: `App`, name: `App`,
components: { components: {
Loading,
CodemirrorEditor, CodemirrorEditor,
}, },
data() {
return {
loading: true,
}
},
mounted() {
setTimeout(() => {
this.loading = false
}, 100)
},
} }
</script> </script>