How to make animation on scroll ?
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%;
}
}
Author And Source
この問題について(How to make animation on scroll ?), 我々は、より多くの情報をここで見つけました https://qiita.com/zurivan/items/77f092fed32f19ab0724著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .