Skip to content

Commit

Permalink
fix: the lost animation (doocs#175)
Browse files Browse the repository at this point in the history
- 恢复移除的 css 代码,并将其并入 `<Loading>` 组件当中
- 动画控制迁移至 `<Loading>`
  • Loading branch information
YangFong authored Aug 8, 2022
1 parent dd4fe6f commit 7ea2104
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 39 deletions.
68 changes: 50 additions & 18 deletions src/components/Loading.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
<template>
<div class="loading" id="loading">
<div class="loading-wrapper">
<div class="loading-anim"></div>
<div class="loading-text">致力于让 Markdown 编辑更简单</div>
<transition name="fade" v-if="loading">
<div class="loading">
<div class="loading-wrapper">
<div class="loading-anim"></div>
<div class="loading-text">致力于让 Markdown 编辑更简单</div>
</div>
</div>
</div>
</transition>
</template>

<script></script>
<script>
export default {
name: `Loading`,
data() {
return {
loading: true,
}
},
mounted() {
setTimeout(() => {
this.loading = false
}, 100)
},
}
</script>

<style lang="less" scoped>
.loading-wrapper {
position: fixed;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
}
.loading {
text-align: center;
position: fixed;
width: 100%;
height: 100%;
Expand All @@ -30,11 +39,12 @@
background-color: #303133;
}
.loading-text {
font-size: 18px;
font-weight: bold;
margin-top: 26px;
color: #303133;
.loading-wrapper {
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
text-align: center;
}
.loading-anim {
Expand All @@ -44,4 +54,26 @@
background: url('../assets/images/favicon.png') no-repeat;
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>
19 changes: 14 additions & 5 deletions src/views/CodemirrorEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@
@menuTick="onMenuEvent"
@closeMenu="closeRightClickMenu"
/>
<loading></loading>
</div>
</template>
<script>
import editorHeader from '../components/CodemirrorEditor/header'
import aboutDialog from '../components/CodemirrorEditor/aboutDialog'
import insertFormDialog from '../components/CodemirrorEditor/insertForm'
import rightClickMenu from '../components/CodemirrorEditor/rightClickMenu'
import uploadImgDialog from '../components/CodemirrorEditor/uploadImgDialog'
import editorHeader from '@/components/CodemirrorEditor/header'
import aboutDialog from '@/components/CodemirrorEditor/aboutDialog'
import insertFormDialog from '@/components/CodemirrorEditor/insertForm'
import rightClickMenu from '@/components/CodemirrorEditor/rightClickMenu'
import uploadImgDialog from '@/components/CodemirrorEditor/uploadImgDialog'
import Loading from '@/components/Loading'
import {
css2json,
Expand Down Expand Up @@ -143,6 +145,7 @@ export default {
}
},
components: {
Loading,
editorHeader,
aboutDialog,
insertFormDialog,
Expand Down Expand Up @@ -710,20 +713,25 @@ export default {
100% {
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
}
0% {
opacity: 0;
transform: translate3d(3000px, 0, 0);
}
60% {
opacity: 1;
transform: translate3d(-25px, 0, 0);
}
75% {
transform: translate3d(10px, 0, 0);
}
90% {
transform: translate3d(-5px, 0, 0);
}
100% {
transform: none;
}
Expand All @@ -733,6 +741,7 @@ export default {
overflow-x: auto;
}
</style>

<style lang="less" scoped>
@import url('../assets/less/app.less');
</style>
17 changes: 1 addition & 16 deletions src/views/index.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
<template>
<transition name="fade" v-if="loading">
<loading />
</transition>
<codemirror-editor v-else />
<codemirror-editor />
</template>

<script>
import Loading from '../components/Loading'
import CodemirrorEditor from './CodemirrorEditor'
export default {
name: `App`,
components: {
Loading,
CodemirrorEditor,
},
data() {
return {
loading: true,
}
},
mounted() {
setTimeout(() => {
this.loading = false
}, 100)
},
}
</script>

Expand Down

0 comments on commit 7ea2104

Please sign in to comment.