Answer the question
In order to leave comments, you need to log in
How to fix JavaScript?
I use this solution to animate elements:
$(window).scroll(function() {
$('#example-14').each(function(){
var imagePos = $(this).offset().top;
var topOfWindow = $(window).scrollTop();
if (imagePos < topOfWindow+600) {
$('.device-arrow14').addClass("slideUp");
}
});
});
#example-14{
text-align: center;
}
#example-14 .device-arrow14{
width: 100%;
visibility: hidden;
margin: 0 auto;
}
#example-14{
text-align: center;
}
.slideUp{
animation-name: slideUp;
-webkit-animation-name: slideUp;
animation-duration: 1s;
-webkit-animation-duration: 1s;
animation-timing-function: ease;
-webkit-animation-timing-function: ease;
visibility: visible !important;
}
@keyframes slideUp {
0% {
transform: translateY(100%);
}
50%{
transform: translateY(-8%);
}
65%{
transform: translateY(4%);
}
80%{
transform: translateY(-4%);
}
95%{
transform: translateY(2%);
}
100% {
transform: translateY(0%);
}
}
@-webkit-keyframes slideUp {
0% {
-webkit-transform: translateY(100%);
}
50%{
-webkit-transform: translateY(-8%);
}
65%{
-webkit-transform: translateY(4%);
}
80%{
-webkit-transform: translateY(-4%);
}
95%{
-webkit-transform: translateY(2%);
}
100% {
-webkit-transform: translateY(0%);
}
}
<section id="example-4">
<div class="device-arrow4">
Анимируемый элемент
</div>
</section>
Answer the question
In order to leave comments, you need to log in
$( document ).ready(function() {
здесь код, который сработает когда страница загружена:
$('.device-arrow14').addClass("slideUp");
});
Well, here is this piece
$('#example-14').each(function(){
var imagePos = $(this).offset().top;
var topOfWindow = $(window).scrollTop();
if (imagePos < topOfWindow+600) {
$('.device-arrow14').addClass("slideUp");
}
});
var topOfWindow = window.scrollY;
function myScroll() {
$('#example-14').each(function(){
var imagePos = $(this).offset().top;
topOfWindow = $(window).scrollTop();
if (imagePos < topOfWindow+600) {
$('.device-arrow14').addClass("slideUp");
}
});
}
myScroll();
$(window).scroll(function() {
myScroll();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question