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

Conversation

frederickjansen
Copy link

Right now, only two blocks at any given time are being animated. On large screen resolutions or with small block sizes, this can cause animations to jump from their starting position to somewhere halfway through the animation. Or if you scroll really fast past an animation and then scroll slowly to it, you'll the animation stuck halfway and then jump to its initial position once it starts animating.

You can see this behaviour on your demo as well, especially with the word "easing".

Screenshot

This is the bottom of my screen and the animation is stuck somewhere below.

@marksyzm
Copy link

Maybe this should be set as a system wide option, so people with very complex and specific slides can disable this by choice OR have a value that allows you to increase the range i.e. 2 = 2 blocks before and after those within viewport, -1 = infinite blocks

@hirbod
Copy link

hirbod commented Aug 29, 2013

This Fix really made my day... thanks a lot!

@marksyzm
Copy link

Just tried it out... works really well and fixed a few issues for me too. Many thanks!

@frederickjansen
Copy link
Author

You're both welcome. I still hope it makes it into the project, since it's John's most popular one when you look at stars.

@doughamlin
Copy link

@frederickjansen

This patch is causing an error for me:

Uncaught TypeError: Cannot call method 'animate' of undefined main.js:9
(anonymous function) main.js:9
(anonymous function) main.js:17

My main.js:

(function($) {
  var viewportHeight = $(window).height();
  var scrollorama = $.scrollorama({
    blocks: '.block',
    enablePin: false
  });
  scrollorama
    .animate('#dp1 label', { delay: 500, duration: viewportHeight*1.5, property: 'top', start: 218, end: 0 })
    .animate('#dp2 label', { delay: 150, duration: viewportHeight*1.5, property: 'top', start: 325, end: 0 })
    .animate('#b3', { delay: 150, duration: viewportHeight*1.5, property: 'background-position-y', start: 500, end: 0 })
    .animate('#dp3 label', { delay: 250, duration: viewportHeight*1.5, property: 'top', start: 225, end: 0 })
    .animate('#dp4 label', { delay: 250, duration: viewportHeight*1.5, property: 'top', start: 225, end: 0 })
    .animate('#dp5 label', { delay: 250, duration: viewportHeight*1.5, property: 'top', start: 225, end: 0 })
    .animate('#dp6 label', { delay: 250, duration: viewportHeight*1.5, property: 'top', start: 500, end: 0 })
    .animate('#dp7 label', { delay: 650, duration: viewportHeight*1.5, property: 'top', start: 500, end: 0 })
    .animate('#dp8 label', { delay: 1550, duration: viewportHeight*1.5, property: 'top', start: 500, end: 0 });
})(jQuery);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants