LoginSignup
1
1

More than 5 years have passed since last update.

How to make animation on scroll ?

Last updated at Posted at 2018-11-16

There have so many animation for icon scroll, but today we will do animation type arrow run down like animated last post.

Start with element html

You just simple put html will is:
<div class="icon-scroll"></div>
and if you use pug to code it will is:
.icon-scroll

Start with scss

*There're we will create square color orange has width 80px:

.icon-scroll{
  background: #ec8806;
  position: relative;
  z-index: 10;;
  cursor: pointer;
  width: 90px;
  left: 0;
  right: 0;
  top: 20px;
  padding-bottom: 45px;
  margin: auto;
  color: #fff;
  text-align: center;
  transition: 2s;
}

*Next, we will add two Pseudo-Elements is before and after like this:

before:
   &:before{
    content: "";
    display: block;
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    margin: auto;
    width: 1px;
    height: 18px;
    background-color: #FFF;
    transform-origin: left bottom;
    transform: scaleY(0) rotate(70deg);
    animation: arrowA 1.8s ease-in-out 0s infinite;
   }
after:
   &:after{
     content: "";
     position: absolute;
     width: 1px;
     height: 40px;
     margin: auto;
     bottom: 0;
     left: 0;
     right: 0;
     animation: arrowB 1.8s ease-in-out 0s infinite;
     background-color: #FFF;
   }

Start with keyframes

Keyframes arrowA for before:
@keyframes arrowA {
  0% {
    transform:rotate(35deg) scaleY(0) translate(0px, 0px);
    height: 15px;
  }
  40% {
    transform:rotate(35deg) scaleY(0) translate(0px, 0px);
    height: 15px;
  }
  55% {
    transform:rotate(35deg) scaleY(1) translate(0px, 0px);
    height: 15px;
  }
  80% {
    transform:rotate(35deg) scaleY(1) translate(0px, 0px);
    height: 15px;
  }
  100% {
    transform:rotate(35deg) scaleY(1) translate(0px, -15px);
    height: 0px;
  }
}
Keyframes arrowB for after:
@keyframes arrowB {
  0% {
    transform:scaleY(0);
    transform-origin:50% 0;
  }
  20% {
    transform:scaleY(0);
    transform-origin:50% 0;
  }
  45% {
    transform:scaleY(1);
    transform-origin:50% 0;
  }
  55% {
    transform:scaleY(1);
    transform-origin:50% 100%;
  }
  85% {
    transform:scaleY(0);
    transform-origin:50% 100%;
  }
  100% {
    transform:scaleY(0);
    transform-origin:50% 100%;
  }
}

Done! :innocent:
Ahhhhh... It's so simple... :hugging::hugging::hugging::hugging:
aniamtion.gif

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1