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

Skip pinned element #173

Closed
BenjoJ opened this issue Mar 26, 2015 · 4 comments
Closed

Skip pinned element #173

BenjoJ opened this issue Mar 26, 2015 · 4 comments
Labels

Comments

@BenjoJ
Copy link

BenjoJ commented Mar 26, 2015

Hi. This is a really powerful plugin and I am so glad I stumbled across it.

I have a pinned div element which stretches to the size of the screen and has some basic animation in the form of images sliding in as you scroll.

controller.pin('#Screen2', 4000, {
    anim: (new TimelineLite())
      .append([TweenMax.to(jQuery('#img2'), .5, { css: { marginLeft: 0 } })])
      .append([TweenMax.to(jQuery('#img3'), .5, { css: { marginLeft: 0 } })])
      .append([TweenMax.to(jQuery('#img4'), .5, { css: { marginLeft: 0 } })])
}, 2000);

At the bottom of this "Screen2" element I have a button which fires a scroll event, so the user can skip down to the next screen.

var offset = jQuery("#Screen3").offset();
jQuery("html,body").animate({
    scrollTop: offset.top,
    scrollLeft: offset.left
}, 1000, 'easeOutQuart');

The problem I have is I do not want the animations in the pinned element to fire when the above scroll function is fired. I want it to just scroll to that element smoothly. What happens is that all the elements in the tween animation fire in one by one and when they have finished, the page scrolls to the desired element.

I have tried using the removePin function, but this disables the pin completely after you have scrolled. I tried firing the controller.pin function again after the scroll event has finished, but this causes the screen to jump back up to the pinned element (Screen2).

Is there anything I can do to get around this please?

Thanks

Ben

@janpaepke
Copy link
Collaborator

Hi Ben!

Glad you like the plugin.
Superscrollorama has ben superseded by ScrollMagic.
The logic is quite similar and I'm sure you'll have an easy time refactoring your code to ScrollMagic.

Once you did, you can make use of ScrollMagic's "enabled" method to temporarily disable the animations from happening: http://janpaepke.github.io/ScrollMagic/docs/ScrollMagic.Scene.html#enabled

Should you have any problems moving to ScrollMagic or implementing this, please follow ScrollMagic's troubleshooting guide and/or post an issue.

best regards,
Jan

@BenjoJ
Copy link
Author

BenjoJ commented Mar 26, 2015

Ah, perfect thanks. I'll give it a go.

@BenjoJ
Copy link
Author

BenjoJ commented Mar 31, 2015

Hi Jan

I am using the 'enabled' method, but it appears to only work the first time I am using it. When the function below is called for the first time, it does indeed disable the scene. However, from then on, calling this function does not seem to disable the scene. Am I doing something incorrectly here?

function scrollToEl(sID) {
if (jQuery(sID).length) {
PhilosophyScene.enabled(false);
var offset = jQuery(sID).offset();
jQuery("html,body").animate({
scrollTop: offset.top - 0,
scrollLeft: offset.left
}, 1000, 'easeOutQuart', function () { PhilosophyScene.enabled(true) });
}

}

Thanks for your continued support.

Ben

@janpaepke
Copy link
Collaborator

It looks like ScrollMagic code.
Please repost it in ScrollMagic support and try to give more context. A jsfiddle if possible.

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

No branches or pull requests

2 participants