A
A
Artyom Albe2018-05-31 17:13:25
JavaScript
Artyom Albe, 2018-05-31 17:13:25

Animation on scroll event?

Hello! There is a site https://www.os-design.ru/ where in the portfolio block the effect of gluing photos is implemented when scrolling the page up and down. I need to implement the same effect on the site creart-design.ru/portfolio . I managed to do only gluing photos when scrolling down, but I don’t understand how to do it up.
window.addEventListener('scroll', function() {
var portfolio_div_cord = document.getElementById('portfolio').getBoundingClientRect();
var portfolio_div_el = document.getElementById('portfolio').children;
posTop = (window.pageYOffset != = undefined) ?window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
for ( i = 0; i <= portfolio_div_el.length; i++) {
var cord_y_top = Math.round(portfolio_div_el[i].offsetTop);
var win_height = document.documentElement.clientHeight;
if ((posTop + 400) >= cord_y_top ) {
portfolio_div_el[i].style.transform = "translateY(0)";
} else if (posTo <= cord_y_top ) {
portfolio_div_el[i].style.transform = "translateY(15px)";
}
}
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question