Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Animate all blocks that are within the viewport, not just two #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions js/jquery.scrollorama.js
Expand Up @@ -101,6 +101,7 @@
function onScrollorama() { function onScrollorama() {
var scrollTop = $(window).scrollTop(), var scrollTop = $(window).scrollTop(),
currBlockIndex = getCurrBlockIndex(scrollTop), currBlockIndex = getCurrBlockIndex(scrollTop),
wheight = $(window).height(),
i, j, anim, startAnimPos, endAnimPos, animPercent, animVal; i, j, anim, startAnimPos, endAnimPos, animPercent, animVal;


// update all animations // update all animations
Expand Down Expand Up @@ -135,7 +136,7 @@
} }


// otherwise, set values per scroll position // otherwise, set values per scroll position
if (i === currBlockIndex || (currBlockIndex === i-1 && anim.baseline === 'bottom')) { if (blocks[i].top + blocks[i].block.height() >= scrollTop && blocks[i].top <= (scrollTop + wheight)) {
// if block gets pinned, set position fixed // if block gets pinned, set position fixed
if (blocks[i].pin && currBlockIndex === i) { if (blocks[i].pin && currBlockIndex === i) {
blocks[i].block blocks[i].block
Expand All @@ -145,7 +146,7 @@


// set start and end animation positions // set start and end animation positions
startAnimPos = blocks[i].top + anim.delay; startAnimPos = blocks[i].top + anim.delay;
if (anim.baseline === 'bottom') { startAnimPos -= $(window).height(); } if (anim.baseline === 'bottom') { startAnimPos -= wheight; }
endAnimPos = startAnimPos + anim.duration; endAnimPos = startAnimPos + anim.duration;


// if scroll is before start of animation, set to start value // if scroll is before start of animation, set to start value
Expand Down