naive-ui/styles/themes/transition.scss

261 lines
9.3 KiB
SCSS
Raw Normal View History

2020-02-11 14:44:29 +08:00
@mixin fade-down-transition ($name: 'fade-down', $from-offset: -4px) {
&.#{$namespace}-#{$name}-transition-enter, &.#{$namespace}-#{$name}-transition-leave-to {
opacity: 0;
transform: translateY($from-offset);
}
&.#{$namespace}-#{$name}-transition-enter-to, &.#{$namespace}-#{$name}-transition-leave {
opacity: 1;
transform: translateY(0);
}
&.#{$namespace}-#{$name}-transition-leave-active {
transition: opacity .3s $--n-ease-in-out-cubic-bezier, transform .3s $--n-ease-in-out-cubic-bezier;
}
&.#{$namespace}-#{$name}-transition-enter-active {
transition: opacity .3s $--n-ease-in-out-cubic-bezier, transform .3s $--n-ease-in-out-cubic-bezier;
}
}
@mixin fade-in-scale-up-transition ($name: 'fade-in-scale-up', $origin: inherit, $duration: .2s, $start-scale: 0.9, $original-transform: (), $original-transition: ()) {
&.#{$namespace}-#{$name}-transition-leave-active {
transform-origin: $origin;
transition: opacity $duration $--n-ease-in-cubic-bezier, transform $duration $--n-ease-in-cubic-bezier, $original-transition;
}
&.#{$namespace}-#{$name}-transition-enter-active {
transform-origin: $origin;
transition: opacity $duration $--n-ease-out-cubic-bezier, transform $duration $--n-ease-out-cubic-bezier, $original-transition;
}
&.#{$namespace}-#{$name}-transition-enter, &.#{$namespace}-#{$name}-transition-leave-to {
opacity: 0;
transform: scale($start-scale) $original-transform;
}
&.#{$namespace}-#{$name}-transition-leave, &.#{$namespace}-#{$name}-transition-enter-to {
opacity: 1;
transform: $--n-transform-debounce-scale $original-transform;
}
}
@mixin fade-in-transition ($name: 'fade-in', $enter-duration: .2s, $leave-duration: .2s) {
&.#{$namespace}-#{$name}-transition-enter-active {
transition: all $enter-duration $--n-ease-in-out-cubic-bezier !important;
}
&.#{$namespace}-#{$name}-transition-leave-active {
transition: all $leave-duration $--n-ease-in-out-cubic-bezier !important;
}
&.#{$namespace}-#{$name}-transition-enter,
&.#{$namespace}-#{$name}-transition-leave-to {
opacity: 0;
}
&.#{$namespace}-#{$name}-transition-enter-to,
&.#{$namespace}-#{$name}-transition-leave {
opacity: 1;
}
}
2020-02-11 17:19:00 +08:00
@mixin slide-in-from-right-transition ($name: 'slide-in-from-right', $duration: .3s, $leave-duration: .2s) {
&.#{$namespace}-#{$name}-transition-leave-active {
2020-02-11 14:44:29 +08:00
transition: transform $leave-duration $--n-ease-in-cubic-bezier;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter-active {
2020-02-11 14:44:29 +08:00
transition: transform $duration $--n-ease-out-cubic-bezier;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter-to {
2020-02-11 14:44:29 +08:00
transform: translateX(0);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter {
2020-02-11 14:44:29 +08:00
transform: translateX(100%);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave {
2020-02-11 14:44:29 +08:00
transform: translateX(0);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave-to {
2020-02-11 14:44:29 +08:00
transform: translateX(100%);
}
}
2020-02-11 17:19:00 +08:00
@mixin slide-in-from-top-transition ($name: 'slide-in-from-top', $duration: .3s, $leave-duration: .2s) {
&.#{$namespace}-#{$name}-transition-leave-active {
2020-02-11 14:44:29 +08:00
transition: transform $leave-duration $--n-ease-in-cubic-bezier;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter-active {
2020-02-11 14:44:29 +08:00
transition: transform $duration $--n-ease-out-cubic-bezier;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter-to {
2020-02-11 14:44:29 +08:00
transform: translateY(0);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter {
2020-02-11 14:44:29 +08:00
transform: translateY(-100%);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave {
2020-02-11 14:44:29 +08:00
transform: translateY(0);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave-to {
2020-02-11 14:44:29 +08:00
transform: translateY(-100%);
}
}
2020-02-11 17:19:00 +08:00
@mixin slide-in-from-bottom-transition ($name: 'slide-in-from-bottom', $duration: .3s, $leave-duration: .2s) {
&.#{$namespace}-#{$name}-transition-leave-active {
2020-02-11 14:44:29 +08:00
transition: transform $leave-duration $--n-ease-in-cubic-bezier;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter-active {
2020-02-11 14:44:29 +08:00
transition: transform $duration $--n-ease-out-cubic-bezier;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter-to {
2020-02-11 14:44:29 +08:00
transform: translateY(0);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter {
2020-02-11 14:44:29 +08:00
transform: translateY(100%);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave {
2020-02-11 14:44:29 +08:00
transform: translateY(0);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave-to {
2020-02-11 14:44:29 +08:00
transform: translateY(100%);
}
}
2020-02-11 17:19:00 +08:00
@mixin slide-in-from-left-transition ($name: 'slide-in-from-left', $duration: .3s, $leave-duration: .2s) {
&.#{$namespace}-#{$name}-transition-leave-active {
2020-02-11 14:44:29 +08:00
transition: transform $duration $--n-ease-in-cubic-bezier;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter-active {
2020-02-11 14:44:29 +08:00
transition: transform $duration $--n-ease-out-cubic-bezier;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter-to {
2020-02-11 14:44:29 +08:00
transform: translateX(0);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter {
2020-02-11 14:44:29 +08:00
transform: translateX(-100%);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave {
2020-02-11 14:44:29 +08:00
transform: translateX(0);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave-to {
2020-02-11 14:44:29 +08:00
transform: translateX(-100%);
}
}
@mixin fade-in-height-expand-transition (
$name: 'fade-in-height-expand',
$duration: .3s,
$original-transition: (),
$leave-delay: 0s,
$fold-padding: false
) {
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave, &.#{$namespace}-#{$name}-transition-enter-to {
2020-02-11 14:44:29 +08:00
opacity: 1;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave-to, &.#{$namespace}-#{$name}-transition-enter {
2020-02-11 14:44:29 +08:00
opacity: 0;
@if $fold-padding {
padding-top: 0 !important;
padding-bottom: 0 !important;
}
2020-02-11 14:44:29 +08:00
margin-top: 0 !important;
margin-bottom: 0 !important;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave-active {
2020-02-11 14:44:29 +08:00
overflow: hidden;
transition:
2020-02-16 21:52:38 +08:00
max-height $duration $--n-ease-in-out-cubic-bezier $leave-delay,
opacity $duration $--n-ease-out-cubic-bezier $leave-delay,
margin-top $duration $--n-ease-in-out-cubic-bezier $leave-delay,
margin-bottom $duration $--n-ease-in-out-cubic-bezier $leave-delay,
padding-top $duration $--n-ease-in-out-cubic-bezier $leave-delay,
padding-bottom $duration $--n-ease-in-out-cubic-bezier $leave-delay,
2020-02-11 17:19:00 +08:00
$original-transition;
2020-02-11 14:44:29 +08:00
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter-active {
2020-02-11 14:44:29 +08:00
overflow: hidden;
2020-02-11 17:19:00 +08:00
transition:
max-height $duration $--n-ease-in-out-cubic-bezier,
2020-02-11 14:44:29 +08:00
opacity $duration $--n-ease-in-cubic-bezier,
margin-top $duration $--n-ease-in-out-cubic-bezier,
2020-02-11 17:19:00 +08:00
margin-bottom $duration $--n-ease-in-out-cubic-bezier,
padding-top $duration $--n-ease-in-out-cubic-bezier,
padding-bottom $duration $--n-ease-in-out-cubic-bezier,
2020-02-11 17:19:00 +08:00
$original-transition;
2020-02-11 14:44:29 +08:00
}
}
@mixin fade-in-width-expand-transition ($name: 'fade-in-width-expand', $duration: .2s, $delay: .1s) {
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave-active {
2020-02-11 14:44:29 +08:00
transition: opacity $duration $--n-ease-in-out-cubic-bezier, max-width $duration $--n-ease-in-out-cubic-bezier $delay,
margin-left $duration $--n-ease-in-out-cubic-bezier $delay,
margin-right $duration $--n-ease-in-out-cubic-bezier $delay;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter-active {
2020-02-11 14:44:29 +08:00
transition: opacity $duration $--n-ease-in-out-cubic-bezier $delay, max-width $duration $--n-ease-in-out-cubic-bezier,
margin-left $duration $--n-ease-in-out-cubic-bezier,
margin-right $duration $--n-ease-in-out-cubic-bezier;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter-to {
2020-02-11 14:44:29 +08:00
opacity: 1;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter {
2020-02-11 14:44:29 +08:00
max-width: 0;
margin-left: 0 !important;
margin-right: 0 !important;
opacity: 0!important;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave {
2020-02-11 14:44:29 +08:00
opacity: 1;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave-to {
2020-02-11 14:44:29 +08:00
max-width: 0 !important;
opacity: 0 !important;
margin-left: 0 !important;
margin-right: 0 !important;
}
}
@mixin fade-up-width-expand-transition ($name: 'fade-up-width-expand', $duration: .2s) {
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave-active {
2020-02-11 14:44:29 +08:00
transition: opacity $duration $--n-ease-out-cubic-bezier, max-width $duration $--n-ease-out-cubic-bezier, transform $duration $--n-ease-out-cubic-bezier;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter-active {
2020-02-11 14:44:29 +08:00
transition: opacity $duration $--n-ease-out-cubic-bezier, max-width $duration $--n-ease-out-cubic-bezier, transform $duration $--n-ease-out-cubic-bezier;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter-to {
2020-02-11 14:44:29 +08:00
opacity: 1;
transform: translateX(0) translateY(0);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-enter {
2020-02-11 14:44:29 +08:00
max-width: 0!important;
opacity: 0;
transform: translateY(60%);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave {
2020-02-11 14:44:29 +08:00
opacity: 1;
transform: translateY(0);
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-#{$name}-transition-leave-to {
2020-02-11 14:44:29 +08:00
max-width: 0!important;
opacity: 0!important;
transform: translateY(60%);
}
}
2020-02-11 17:19:00 +08:00
@mixin icon-switch-transition (
$original-transform: (),
$left: 0,
$top: 0,
$transition: (all .3s $--n-ease-in-out-cubic-bezier !important)
) {
&.#{$namespace}-icon-switch-transition-enter, &.#{$namespace}-icon-switch-transition-leave-to {
2020-02-11 14:44:29 +08:00
/* make sure it apply to element */
transform: $original-transform scale(.75);
opacity: 0;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-icon-switch-transition-enter-to, &.#{$namespace}-icon-switch-transition-leave {
2020-02-11 14:44:29 +08:00
transform: $--n-transform-debounce-scale $original-transform;
opacity: 1;
}
2020-02-11 17:19:00 +08:00
&.#{$namespace}-icon-switch-transition-leave-active, &.#{$namespace}-icon-switch-transition-enter-active {
2020-02-11 14:44:29 +08:00
transform-origin: center;
position: absolute;
left: $left;
top: $top;
2020-02-11 17:19:00 +08:00
transition: $transition;
2020-02-11 14:44:29 +08:00
}
}