Skip to content

Commit

Permalink
Add animation less back
Browse files Browse the repository at this point in the history
  • Loading branch information
WangHansen committed Apr 23, 2023
1 parent 58d13a2 commit 934de6b
Show file tree
Hide file tree
Showing 9 changed files with 268 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@
document.removeEventListener('mousedown', timekeeping);
});
</script>

<style lang="less">
@import 'styles/index.less';
</style>
1 change: 1 addition & 0 deletions src/styles/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'transition/index.less';
18 changes: 18 additions & 0 deletions src/styles/transition/base.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.transition-default() {
&-enter-active,
&-leave-active {
transition: 0.3s cubic-bezier(0.25, 0.8, 0.5, 1) !important;
}

&-move {
transition: transform 0.4s;
}
}

.expand-transition {
.transition-default();
}

.expand-x-transition {
.transition-default();
}
81 changes: 81 additions & 0 deletions src/styles/transition/fade.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.2s ease-in-out;
}

.fade-enter-from,
.fade-leave-to {
opacity: 0;
}

/* fade-slide */
.fade-slide-leave-active,
.fade-slide-enter-active {
transition: all 0.3s;
}

.fade-slide-enter-from {
opacity: 0;
transform: translateX(-30px);
}

.fade-slide-leave-to {
opacity: 0;
transform: translateX(30px);
}

// ///////////////////////////////////////////////
// Fade Bottom
// ///////////////////////////////////////////////

// Speed: 1x
.fade-bottom-enter-active,
.fade-bottom-leave-active {
transition: opacity 0.25s, transform 0.3s;
}

.fade-bottom-enter-from {
opacity: 0;
transform: translateY(-10%);
}

.fade-bottom-leave-to {
opacity: 0;
transform: translateY(10%);
}

// fade-scale
.fade-scale-leave-active,
.fade-scale-enter-active {
transition: all 0.28s;
}

.fade-scale-enter-from {
opacity: 0;
transform: scale(1.2);
}

.fade-scale-leave-to {
opacity: 0;
transform: scale(0.8);
}

// ///////////////////////////////////////////////
// Fade Top
// ///////////////////////////////////////////////

// Speed: 1x
.fade-top-enter-active,
.fade-top-leave-active {
transition: opacity 0.2s, transform 0.25s;
}

.fade-top-enter-from {
opacity: 0;
transform: translateY(8%);
}

.fade-top-leave-to {
opacity: 0;
transform: translateY(-8%);
}
10 changes: 10 additions & 0 deletions src/styles/transition/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@import './base.less';
@import './fade.less';
@import './scale.less';
@import './slide.less';
@import './scroll.less';
@import './zoom.less';

.collapse-transition {
transition: 0.2s height ease-in-out, 0.2s padding-top ease-in-out, 0.2s padding-bottom ease-in-out;
}
21 changes: 21 additions & 0 deletions src/styles/transition/scale.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.scale-transition {
.transition-default();

&-enter-from,
&-leave,
&-leave-to {
opacity: 0;
transform: scale(0);
}
}

.scale-rotate-transition {
.transition-default();

&-enter-from,
&-leave,
&-leave-to {
opacity: 0;
transform: scale(0) rotate(-45deg);
}
}
67 changes: 67 additions & 0 deletions src/styles/transition/scroll.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
.scroll-y-transition {
.transition-default();

&-enter-from,
&-leave-to {
opacity: 0;
}

&-enter-from {
transform: translateY(-15px);
}

&-leave-to {
transform: translateY(15px);
}
}

.scroll-y-reverse-transition {
.transition-default();

&-enter-from,
&-leave-to {
opacity: 0;
}

&-enter-from {
transform: translateY(15px);
}

&-leave-to {
transform: translateY(-15px);
}
}

.scroll-x-transition {
.transition-default();

&-enter-from,
&-leave-to {
opacity: 0;
}

&-enter-from {
transform: translateX(-15px);
}

&-leave-to {
transform: translateX(15px);
}
}

.scroll-x-reverse-transition {
.transition-default();

&-enter-from,
&-leave-to {
opacity: 0;
}

&-enter-from {
transform: translateX(15px);
}

&-leave-to {
transform: translateX(-15px);
}
}
39 changes: 39 additions & 0 deletions src/styles/transition/slide.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.slide-y-transition {
.transition-default();

&-enter-from,
&-leave-to {
opacity: 0;
transform: translateY(-15px);
}
}

.slide-y-reverse-transition {
.transition-default();

&-enter-from,
&-leave-to {
opacity: 0;
transform: translateY(15px);
}
}

.slide-x-transition {
.transition-default();

&-enter-from,
&-leave-to {
opacity: 0;
transform: translateX(-15px);
}
}

.slide-x-reverse-transition {
.transition-default();

&-enter-from,
&-leave-to {
opacity: 0;
transform: translateX(15px);
}
}
27 changes: 27 additions & 0 deletions src/styles/transition/zoom.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// zoom-out
.zoom-out-enter-active,
.zoom-out-leave-active {
transition: opacity 0.1 ease-in-out, transform 0.15s ease-out;
}

.zoom-out-enter-from,
.zoom-out-leave-to {
opacity: 0;
transform: scale(0);
}

// zoom-fade
.zoom-fade-enter-active,
.zoom-fade-leave-active {
transition: transform 0.2s, opacity 0.3s ease-out;
}

.zoom-fade-enter-from {
opacity: 0;
transform: scale(0.92);
}

.zoom-fade-leave-to {
opacity: 0;
transform: scale(1.06);
}

0 comments on commit 934de6b

Please sign in to comment.