// Animation

@mixin make-motion($className, $keyframeName, $duration, $time-function-in, $time-function-out) {
  .#{$className}-enter-active,
  .#{$className}-appear,
  .#{$className}-leave-active{
    animation-duration: $duration;
    animation-fill-mode: both;
  }

  .#{$className}-enter-active,
  .#{$className}-enter-to,
  .#{$className}-appear {
    animation-name: #{$keyframeName}In;
    animation-timing-function: $time-function-in;
  }

  .#{$className}-leave-active,
  .#{$className}-leave-to {
    animation-name: #{$keyframeName}Out;
    animation-timing-function: $time-function-out;
  }
}

//
// fade
//

@include make-motion(fade, aidFade, $animation-time, linear, linear);
@include make-motion(fade-slow, aidFade, $animation-time-lg, linear, linear);

@keyframes aidFadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes aidFadeOut {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}


//
// ease (已废弃)
//

@include make-motion(ease, aidEase, $animation-time, linear, linear);

@keyframes aidEaseIn {
  0% {
    opacity: 0;
    transform: scale(.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes aidEaseOut {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(.9);
  }
}


//
// zoom
//

@include make-motion(zoom, aidZoom, $animation-time, linear, linear);
@include make-motion(zoom-up, aidZoomUp, $animation-time, linear, linear);
@include make-motion(zoom-right, aidZoomRight, $animation-time, linear, linear);
@include make-motion(zoom-down, aidZoomDown, $animation-time, linear, linear);
@include make-motion(zoom-left, aidZoomLeft, $animation-time, linear, linear);

@include make-motion(zoom-slow, aidZoom, $animation-time-lg, linear, linear);
@include make-motion(zoom-up-slow, aidZoomUp, $animation-time-lg, linear, linear);
@include make-motion(zoom-right-slow, aidZoomRight, $animation-time-lg, linear, linear);
@include make-motion(zoom-down-slow, aidZoomDown, $animation-time-lg, linear, linear);
@include make-motion(zoom-left-slow, aidZoomLeft, $animation-time-lg, linear, linear);

@keyframes aidZoomIn {
  from {
    opacity: 0;
    transform: scale3d(.8, .8, .8);
  }

  100% {
    opacity: 1;
  }
}

@keyframes aidZoomOut {
  from {
    opacity: 1;
    transform: scale3d(1, 1, 1);
  }

  100% {
    opacity: 0;
    transform: scale3d(.8, .8, .8);
  }
}

@keyframes aidZoomUpIn {
  from {
    opacity: .5;
    transform: translate3d(0, 100%, 0) scale3d(.8, .8, .8);
  }

  40%,
  60% {
    opacity: .5;
    transform: translate3d(0, 0, 0) scale3d(.8, .8, .8);
  }

  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale3d(1, 1, 1);
  }
}

@keyframes aidZoomUpOut {
  40%,
  60% {
    opacity: .5;
    transform: translate3d(0, 0, 0) scale3d(.8, .8, .8);
  }

  to {
    opacity: .5;
    transform: translate3d(0, -100%, 0) scale3d(.8, .8, .8);
  }
}

@keyframes aidZoomRightIn {
  from {
    opacity: .5;
    transform: translate3d(100%, 0, 0) scale3d(.8, .8, .8);
  }

  40%,
  60% {
    opacity: .5;
    transform: translate3d(0, 0, 0) scale3d(.8, .8, .8);
  }

  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale3d(1, 1, 1);
  }
}

@keyframes aidZoomRightOut {
  40%,
  60% {
    opacity: .5;
    transform: translate3d(0, 0, 0) scale3d(.8, .8, .8);
  }

  to {
    opacity: .5;
    transform: translate3d(100%, 0, 0) scale(.8);
  }
}

@keyframes aidZoomDownIn {
  from {
    opacity: .5;
    transform: translate3d(0, -100%, 0) scale3d(.8, .8, .8);
  }

  40%,
  60% {
    opacity: .5;
    transform: translate3d(0, 0, 0) scale3d(.8, .8, .8);
  }

  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale3d(1, 1, 1);
  }
}

@keyframes aidZoomDownOut {
  40%,
  60% {
    opacity: .5;
    transform: translate3d(0, 0, 0) scale3d(.8, .8, .8);
  }

  to {
    opacity: .5;
    transform: translate3d(0, 100%, 0) scale3d(.8, .8, .8);
  }
}

@keyframes aidZoomLeftIn {
  from {
    opacity: .5;
    transform: translate3d(-100%, 0, 0) scale3d(.8, .8, .8);
  }

  40%,
  60% {
    opacity: .5;
    transform: translate3d(0, 0, 0) scale3d(.8, .8, .8);
  }

  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale3d(1, 1, 1);
  }
}

@keyframes aidZoomLeftOut {
  40%,
  60% {
    opacity: .5;
    transform: translate3d(0, 0, 0) scale3d(.8, .8, .8);
  }

  to {
    opacity: .5;
    transform: translate3d(-100%, 0, 0) scale3d(.8, .8, .8);
  }
}


//
// move
//

@include make-motion(move-up, aidMoveUp, $animation-time, ease-out, ease-in);
@include make-motion(move-down, aidMoveDown, $animation-time, ease-out, ease-in);
@include make-motion(move-left, aidMoveLeft, $animation-time, ease-out, ease-in);
@include make-motion(move-right, aidMoveRight, $animation-time, ease-out, ease-in);

@include make-motion(move-up-slow, aidMoveUp, $animation-time-lg, ease-out, ease-in);
@include make-motion(move-down-slow, aidMoveDown, $animation-time-lg, ease-out, ease-in);
@include make-motion(move-left-slow, aidMoveLeft, $animation-time-lg, ease-out, ease-in);
@include make-motion(move-right-slow, aidMoveRight, $animation-time-lg, ease-out, ease-in);

@keyframes aidMoveDownIn {
  0% {
    transform: translateY(100%);
    transform-origin: 0 0;
  }

  100% {
    transform: translateY(0%);
    transform-origin: 0 0;
  }
}

@keyframes aidMoveDownOut {
  0% {
    transform: translateY(0%);
    transform-origin: 0 0;
  }
  100% {
    transform: translateY(100%);
    transform-origin: 0 0;
  }
}

@keyframes aidMoveLeftIn {
  0% {
    transform: translateX(-100%);
    transform-origin: 0 0;
  }
  100% {
    transform: translateX(0%);
    transform-origin: 0 0;
  }
}

@keyframes aidMoveLeftOut {
  0% {
    transform: translateX(0%);
    transform-origin: 0 0;
  }
  100% {
    transform: translateX(-100%);
    transform-origin: 0 0;
  }
}

@keyframes aidMoveRightIn {
  0% {
    transform: translateX(100%);
    transform-origin: 0 0;
  }
  100% {
    transform: translateX(0%);
    transform-origin: 0 0;
  }
}

@keyframes aidMoveRightOut {
  0% {
    transform: translateX(0%);
    transform-origin: 0 0;
  }
  100% {
    transform: translateX(100%);
    transform-origin: 0 0;
  }
}

@keyframes aidMoveUpIn {
  0% {
    transform: translateY(-100%);
    transform-origin: 0 0;
  }
  100% {
    transform: translateY(0%);
    transform-origin: 0 0;
  }
}

@keyframes aidMoveUpOut {
  0% {
    transform: translateY(0%);
    transform-origin: 0 0;
  }
  100% {
    transform: translateY(-100%);
    transform-origin: 0 0;
  }
}


//
// slide
//

@include make-motion(slide-up, aidSlideUp, $animation-time, ease-in-out,ease-in-out);
@include make-motion(slide-down, aidSlideDown, $animation-time, ease-in-out,ease-in-out);
@include make-motion(slide-left, aidSlideLeft, $animation-time, ease-in-out,ease-in-out);
@include make-motion(slide-right, aidSlideRight, $animation-time, ease-in-out,ease-in-out);

@include make-motion(slide-up-slow, aidSlideUp, $animation-time-lg, ease-in-out,ease-in-out);
@include make-motion(slide-down-slow, aidSlideDown, $animation-time-lg, ease-in-out,ease-in-out);
@include make-motion(slide-left-slow, aidSlideLeft, $animation-time-lg, ease-in-out,ease-in-out);
@include make-motion(slide-right-slow, aidSlideRight, $animation-time-lg, ease-in-out,ease-in-out);
@keyframes aidSlideUpIn {
  0% {
    opacity: 0;
    transform: scaleY(.8);
    transform-origin: 0 0;
  }
  100% {
    opacity: 1;
    transform: scaleY(1);
    transform-origin: 0 0;
  }
}

@keyframes aidSlideUpOut {
  0% {
    opacity: 1;
    transform: scaleY(1);
    transform-origin: 0 0;
  }
  100% {
    opacity: 0;
    transform: scaleY(.8);
    transform-origin: 0 0;
  }
}

@keyframes aidSlideDownIn {
  0% {
    opacity: 0;
    transform: scaleY(.8);
    transform-origin: 100% 100%;
  }
  100% {
    opacity: 1;
    transform: scaleY(1);
    transform-origin: 100% 100%;
  }
}

@keyframes aidSlideDownOut {
  0% {
    opacity: 1;
    transform: scaleY(1);
    transform-origin: 100% 100%;
  }
  100% {
    opacity: 0;
    transform: scaleY(.8);
    transform-origin: 100% 100%;
  }
}

@keyframes aidSlideLeftIn {
  0% {
    opacity: 0;
    transform: scaleX(.8);
    transform-origin: 0 0;
  }
  100% {
    opacity: 1;
    transform: scaleX(1);
    transform-origin: 0 0;
  }
}

@keyframes aidSlideLeftOut {
  0% {
    opacity: 1;
    transform: scaleX(1);
    transform-origin: 0 0;
  }
  100% {
    opacity: 0;
    transform: scaleX(.8);
    transform-origin: 0 0;
  }
}

@keyframes aidSlideRightIn {
  0% {
    opacity: 0;
    transform: scaleX(.8);
    transform-origin: 100% 0;
  }
  100% {
    opacity: 1;
    transform: scaleX(1);
    transform-origin: 100% 0;
  }
}

@keyframes aidSlideRightOut {
  0% {
    opacity: 1;
    transform: scaleX(1);
    transform-origin: 100% 0;
  }
  100% {
    opacity: 0;
    transform: scaleX(.8);
    transform-origin: 100% 0;
  }
}


//
// collapse
//

@include make-motion(collapse, aidCollapse, $animation-time, linear,linear);
@include make-motion(collapse-slow, aidCollapse, $animation-time-lg, linear,linear);

@keyframes aidCollapseIn {
  0% {
    height: 0;
    padding: 0;
    overflow: hidden;
  }
}

@keyframes aidCollapseOut {
  100% {
    height: 0;
    padding: 0;
    overflow: hidden;
  }
}


//
// flip
//

@include make-motion(flipY,aidFlipY,$animation-time, ease-out,ease-in);
@include make-motion(flipX,aidFlipX,$animation-time, ease-out,ease-in);
@include make-motion(flipY-reverse,aidFlipYReverse,$animation-time, ease-out,ease-in);
@include make-motion(flipX-reverse,aidFlipXReverse,$animation-time, ease-out,ease-in);
@include make-motion(flipY-right,aidFlipYRight,$animation-time, ease-out,ease-in);
@include make-motion(flipY-left,aidFlipYeft,$animation-time, ease-out,ease-in);

@include make-motion(flipY-slow,aidFlipY,$animation-time-lg, ease-out,ease-in);
@include make-motion(flipX-slow,aidFlipX,$animation-time-lg, ease-out,ease-in);
@include make-motion(flipY-reverse-slow,aidFlipYReverse,$animation-time-lg, ease-out,ease-in);
@include make-motion(flipX-reverse-slow,aidFlipXReverse,$animation-time-lg, ease-out,ease-in);
@include make-motion(flipY-right-slow,aidFlipYRight,.8s, ease-out,ease-in);
@include make-motion(flipY-left-slow,aidFlipYLeft,.8s, ease-out,ease-in);



@keyframes aidFlipYIn {
  from {
    opacity: 0;
    transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
  }

  40% {
    transform: perspective(400px) rotate3d(0, 1, 0, -20deg);
  }

  60% {
    opacity: 1;
    transform: perspective(400px) rotate3d(0, 1, 0, 10deg);
  }

  80% {
    transform: perspective(400px) rotate3d(0, 1, 0, -5deg);
  }

  to {
    transform: perspective(400px);
  }
}

@keyframes aidFlipYOut {
  from {
    transform: perspective(400px);
  }

  30% {
    opacity: 1;
    transform: perspective(400px) rotate3d(0, 1, 0, -15deg);
  }

  to {
    opacity: 0;
    transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
  }
}

@keyframes aidFlipYReverseIn {
  from {
    opacity: 0;
    transform: perspective(400px) rotate3d(0, 1, 0, -90deg);
  }

  40% {
    transform: perspective(400px) rotate3d(0, 1, 0, 20deg);
  }

  60% {
    opacity: 1;
    transform: perspective(400px) rotate3d(0, 1, 0, -10deg);
  }

  80% {
    transform: perspective(400px) rotate3d(0, 1, 0, 5deg);
  }

  to {
    transform: perspective(400px);
  }
}

@keyframes aidFlipYReverseOut {
  from {
    transform: perspective(400px);
  }

  30% {
    opacity: 1;
    transform: perspective(400px) rotate3d(0, 1, 0, 15deg);
  }

  to {
    opacity: 0;
    transform: perspective(400px) rotate3d(0, 1, 0, -90deg);
  }
}

@keyframes aidFlipXIn {
  from {
    opacity: 0;
    transform: perspective(400px) rotate3d(1, 0, 0, 90deg);
  }

  40% {
    transform: perspective(400px) rotate3d(1, 0, 0, -20deg);
  }

  60% {
    opacity: 1;
    transform: perspective(400px) rotate3d(1, 0, 0, 10deg);
  }

  80% {
    transform: perspective(400px) rotate3d(1, 0, 0, -5deg);
  }

  to {
    transform: perspective(400px);
  }
}

@keyframes aidFlipXOut {
  from {
    transform: perspective(400px);
  }

  30% {
    opacity: 1;
    transform: perspective(400px) rotate3d(1, 0, 0, -15deg);
  }

  to {
    opacity: 0;
    transform: perspective(400px) rotate3d(1, 0, 0, 90deg);
  }
}


@keyframes aidFlipXReverseIn {
  from {
    opacity: 0;
    transform: perspective(400px) rotate3d(1, 0, 0, -90deg);
  }

  40% {
    transform: perspective(400px) rotate3d(1, 0, 0, 20deg);
  }

  60% {
    opacity: 1;
    transform: perspective(400px) rotate3d(1, 0, 0, -10deg);
  }

  80% {
    transform: perspective(400px) rotate3d(1, 0, 0, 5deg);
  }

  to {
    transform: perspective(400px);
  }
}

@keyframes aidFlipXReverseOut {
  from {
    transform: perspective(400px);
  }

  30% {
    opacity: 1;
    transform: perspective(400px) rotate3d(1, 0, 0, 15deg);
  }

  to {
    opacity: 0;
    transform: perspective(400px) rotate3d(1, 0, 0, -90deg);
  }
}


@keyframes aidFlipYRightIn {}

@keyframes aidFlipYRightOut {
  from {
    transform: perspective(400px);
  }

  to {
    opacity: 0;
    transform: perspective(400px) translateX(100%) rotate3d(0, 1, 0, 90deg);
  }
}
@keyframes aidFlipYLeftIn {}

@keyframes aidFlipYLeftOut {
  from {
    transform: perspective(400px);
  }

  to {
    opacity: 0;
    transform: perspective(400px) translateX(-100%) rotate3d(0, 1, 0, -90deg);
  }
}



//
// rotate
//

@include make-motion(rotate,aidRotate,$animation-time, linear,linear);
@include make-motion(rotate-slow,aidRotate,$animation-time-lg, linear,linear);

@keyframes aidRotateIn {
  from {
    opacity: 0;
    transform: rotate3d(0, 0, 1, -200deg);
    transform-origin: center;
  }

  to {
    opacity: 1;
    transform: none;
    transform-origin: center;
  }
}

@keyframes aidRotateOut {
  from {
    opacity: 1;
    transform-origin: center;
  }

  to {
    opacity: 0;
    transform: rotate3d(0, 0, 1, 200deg);
    transform-origin: center;
  }
}


//
// bounce
//

@include make-motion(bounce,aidBounce,$animation-time-lg, linear,linear);
@include make-motion(bounce-down,aidBounceDown,$animation-time-lg, linear,linear);
@include make-motion(bounce-left,aidBounceLeft,$animation-time-lg, linear,linear);
@include make-motion(bounce-right,aidBounceRight,$animation-time-lg, linear,linear);
@include make-motion(bounce-up,aidBounceUp,$animation-time-lg, linear,linear);

@keyframes aidBounceIn {
  from,
  20%,
  40%,
  60%,
  80%,
  to {
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
  }

  0% {
    opacity: 0;
    transform: scale3d(.3, .3, .3);
  }

  20% {
    transform: scale3d(1.1, 1.1, 1.1);
  }

  40% {
    transform: scale3d(.9, .9, .9);
  }

  60% {
    opacity: 1;
    transform: scale3d(1.03, 1.03, 1.03);
  }

  80% {
    transform: scale3d(.97, .97, .97);
  }

  to {
    opacity: 1;
    transform: scale3d(1, 1, 1);
  }
}

@keyframes aidBounceOut {
  20% {
    transform: scale3d(.9, .9, .9);
  }

  50%,
  55% {
    opacity: 1;
    transform: scale3d(1.1, 1.1, 1.1);
  }

  to {
    opacity: 0;
    transform: scale3d(.3, .3, .3);
  }
}

@keyframes aidBounceDownIn {
  from, 60%, 75%, 90%, to {
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
  }

  0% {
    opacity: 0;
    transform: translate3d(0, -3000px, 0);
  }

  60% {
    opacity: 1;
    transform: translate3d(0, 25px, 0);
  }

  75% {
    transform: translate3d(0, -10px, 0);
  }

  90% {
    transform: translate3d(0, 5px, 0);
  }

  to {
    transform: none;
  }
}

@keyframes aidBounceDownOut {
  20% {
    transform: translate3d(0, 10px, 0);
  }

  40%, 45% {
    opacity: 1;
    transform: translate3d(0, -20px, 0);
  }

  to {
    opacity: 0;
    transform: translate3d(0, 2000px, 0);
  }
}

@keyframes aidBounceLeftIn {
  from, 60%, 75%, 90%, to {
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
  }

  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);
  }

  to {
    transform: none;
  }
}

@keyframes aidBounceLeftOut {
  20% {
    opacity: 1;
    transform: translate3d(20px, 0, 0);
  }

  to {
    opacity: 0;
    transform: translate3d(-2000px, 0, 0);
  }
}

@keyframes aidBounceRightIn {
  from, 60%, 75%, 90%, to {
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
  }

  from {
    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);
  }

  to {
    transform: none;
  }
}

@keyframes aidBounceRightOut {
  20% {
    opacity: 1;
    transform: translate3d(-20px, 0, 0);
  }

  to {
    opacity: 0;
    transform: translate3d(2000px, 0, 0);
  }
}

@keyframes aidBounceUpIn {
  from, 60%, 75%, 90%, to {
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
  }

  from {
    opacity: 0;
    transform: translate3d(0, 3000px, 0);
  }

  60% {
    opacity: 1;
    transform: translate3d(0, -20px, 0);
  }

  75% {
    transform: translate3d(0, 10px, 0);
  }

  90% {
    transform: translate3d(0, -5px, 0);
  }

  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes aidBounceUpOut {
  20% {
    transform: translate3d(0, -10px, 0);
  }

  40%, 45% {
    opacity: 1;
    transform: translate3d(0, 20px, 0);
  }

  to {
    opacity: 0;
    transform: translate3d(0, -2000px, 0);
  }
}

@import "loop";

// 下面定义的 ‘animation’ 用于 ‘lazyload’ 的动效
@mixin make-lazy-motion($className, $keyframeName, $duration, $time-function-in, $time-function-out) {

  .#{$className}-enter-active,
  .#{$className}-appear {
    animation-duration: $duration;
    animation-fill-mode: both;
  }

  .#{$className}-leave-active,
  .#{$className}-leave-active,
  .#{$className}-leave-to {
    display: none;
  }

  .#{$className}-enter-active,
  .#{$className}-enter-to,
  .#{$className}-appear {
    animation-name: #{$keyframeName}In;
    animation-timing-function: $time-function-in;
  }
}

@include make-lazy-motion(lazyFade, aidFade, $animation-time, linear, linear);
@include make-lazy-motion(lazyZoom, aidZoom, $animation-time, linear, linear);