如何平滑结束动画,即创建滚动时滚轮滚出并平滑停止的效果?
$(window).scroll(function() {
if ($(this).scrollTop() > $(window).height()) {
$('.wheel').addClass("active-left");
} else {};
});
header {
height: 1000px;
background-color: green;
text-transform: uppercase;
}
footer {
height: 600px;
background-color: blue;
}
.wheel {
animation: infinite-spinning 150ms steps(8) infinite;
width: 250px;
height: 250px;
position: relative;
left: -250px;
transition: all 3s ease
}
.wheel.active-left {
left: 0;
animation: infinite-spinning 250ms steps(8) 16;
}
@-webkit-keyframes infinite-spinning {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<header>
прокрути вниз
</header>
<div class="wheel">
<img src="http://www.freepngimg.com/download/car_wheel/2-2-car-wheel-png-picture.png" alt="wheel">
</div>
<footer>
</footer>
例如,像这样: