Jump to content
Search Community

Gsap, smooth scroll for website

taskemiura test
Moderator Tag

Recommended Posts

1 minute ago, ZachSaucier said:

Hey taskemiura and welcome to the GreenSock forums. You can add smooth scrolling to your website using ScrollTrigger's .scrollerProxy() method paired with your favorite smooth scrolling library.

Hi ZachSaucier! Thx for answer!!!

 

Do you mean that I have to use another plugin that's SmoothScrolling?

Smooth scrolling itself works for me, it's just that I have some blocks shifted through the translate: transform and smooth scrolling only work up to the height where this block starts, and not up to the block itself, before its actual beginning

Link to comment
Share on other sites

13 minutes ago, taskemiura said:

Do you mean that I have to use another plugin that's SmoothScrolling?

ScrollTrigger very purposefully avoids doing any sort of scroll-jacking (which is what smooth scrolling functionality requires). However we allow you to support it through the .scrollerProxy() method. Yes, it requires adding another script. But the ones linked to are pretty small in size so it shouldn't be a performance issue in terms of loading another file.

Link to comment
Share on other sites

3 minutes ago, ZachSaucier said:

ScrollTrigger very purposefully avoids doing any sort of scroll-jacking (which is what smooth scrolling functionality requires). However we allow you to support it through the .scrollerProxy() method. Yes, it requires adding another script. But the ones linked to are pretty small in size so it shouldn't be a performance issue in terms of loading another file.

Thx! I try to use .scrollerProxy() method

Link to comment
Share on other sites

Help me to understand! i do as in your example 

See the Pen 1e42c7a73bfa409d2cf1e184e7a4248d?editors=1010 by GreenSock (@GreenSock) on CodePen

 . I connect a third-party library for smooth scrolling - smooth-scrollbar, https://prnt.sc/tvp5fv 

See the Pen vYGBZex by Karaulovskiy (@Karaulovskiy) on CodePen

 at the time of initialization, the scroll breaks, which comes from GSAP !? On a combat project, in general, all animation breaks http://youkon.test.stratosfera.digital/local/templates/main/frontend/assets/main.html

Link to comment
Share on other sites

 

Hey @karaulovskin

 

Actually, you are not quite doing as what the example shows.

 

First things first: Your body has to be styled a certain way for smooth-scrollbar to work on the page.

That is what makes the scroll "break" - actually not "appear" at all - in your example.

 

 

Secondly: You don't even use ScrollTrigger's .scrollerProxy in your pen.

This part is totally missing in your code:

 

ScrollTrigger.scrollerProxy("body", {
  scrollTop(value) {
    if (arguments.length) {
      bodyScrollBar.scrollTop = value;
    }
    return bodyScrollBar.scrollTop;
  }
});

bodyScrollBar.addListener(ScrollTrigger.update);

 

It tells ScrollTrigger to work with the values of smooth-scrollbar plugin so it is rather important if you want to make ScrollTrigger work with a smooth-scrolling script like smooth-scrollbar.

 

 

Lastly:

It is a little tricky  to guess what exactly you want to achieve. Maybe make a demo of the exact effect you want to get without the use of smooth-scrollbar first. I think that would make it easier for others to help you.

 

 

I made a fork of your pen, that does most likely not show the effect you want to achieve, but it  shows how smooth-scrollbar works, and how to use ScrollTrigger's .scrollerProxy in the first-place, to make ScrollTrigger react to smooth-scrollbar's 'scrolling'.

 

See the Pen 6f3f9bb9052263468f90f18a0687ccdb by akapowl (@akapowl) on CodePen

 

 

Since this is rather complex in total, I suggest you dig into learning how to properly set up idiotwu's smooth-scrollbar first:

https://idiotwu.github.io/smooth-scrollbar/

 

and then you dig into how to integrate it properly with GSAP's ScrollTrigger via .scrollerProxy:

https://greensock.com/docs/v3/Plugins/ScrollTrigger/static.scrollerProxy()

 

 

Cheers,

Paul

 

 

[ EDIT: Exchanged codepen-link - now links the pen itself instead of the debug view ]

  • Like 2
Link to comment
Share on other sites

On 8/7/2020 at 3:45 PM, akapowl said:

 

Hey @karaulovskin

 

Actually, you are not quite doing as what the example shows.

 

First things first: Your body has to be styled a certain way for smooth-scrollbar to work on the page.

That is what makes the scroll "break" - actually not "appear" at all - in your example.

 

 

Secondly: You don't even use ScrollTrigger's .scrollerProxy in your pen.

This part is totally missing in your code:

 


ScrollTrigger.scrollerProxy("body", {
  scrollTop(value) {
    if (arguments.length) {
      bodyScrollBar.scrollTop = value;
    }
    return bodyScrollBar.scrollTop;
  }
});

bodyScrollBar.addListener(ScrollTrigger.update);

 

It tells ScrollTrigger to work with the values of smooth-scrollbar plugin so it is rather important if you want to make ScrollTrigger work with a smooth-scrolling script like smooth-scrollbar.

 

 

Lastly:

It is a little tricky  to guess what exactly you want to achieve. Maybe make a demo of the exact effect you want to get without the use of smooth-scrollbar first. I think that would make it easier for others to help you.

 

 

I made a fork of your pen, that does most likely not show the effect you want to achieve, but it  shows how smooth-scrollbar works, and how to use ScrollTrigger's .scrollerProxy in the first-place, to make ScrollTrigger react to smooth-scrollbar's 'scrolling'.

 

 

 

 

 

Since this is rather complex in total, I suggest you dig into learning how to properly set up idiotwu's smooth-scrollbar first:

https://idiotwu.github.io/smooth-scrollbar/

 

and then you dig into how to integrate it properly with GSAP's ScrollTrigger via .scrollerProxy:

https://greensock.com/docs/v3/Plugins/ScrollTrigger/static.scrollerProxy()

 

 

Cheers,

Paul

 

 

[ EDIT: Exchanged codepen-link - now links the pen itself instead of the debug view ]

hi bro, i have in code - ScrollTrigger.scrollerProxy("body", {
  scrollTop(value) {
    if (arguments.length) {
      bodyScrollBar.scrollTop = value;
    }
    return bodyScrollBar.scrollTop;
  }
});

 

Link to comment
Share on other sites

1 hour ago, karaulovskin said:

at the moment the animation using gsap is working correctly. 
Help please screw the smooth scroll

Here's how you could set it up with ASScroll. All I did was replace your content with the content from the demo in the docs:

See the Pen yLOYbMB?editors=1000 by GreenSock (@GreenSock) on CodePen

 

1 hour ago, karaulovskin said:

How the *%$# can I get this garbage to work with each other?

That's not very professional. If you think ScrollTrigger or GSAP is garbage then why not write your own that's better? Additionally we're helping you for free, so please at least be courteous and professional in the forums.

  • Like 3
Link to comment
Share on other sites

4 minutes ago, ZachSaucier said:

Here's how you could set it up with ASScroll. All I did was replace your content with the content from the demo in the docs:

 

 

 

That's not very professional. If you think ScrollTrigger or GSAP is garbage then why not write your own that's better? Additionally we're helping you for free, so please at least be courteous and professional in the forums.

thank you bro, I didn't want to offend you in any way. It's just my bad English!

Link to comment
Share on other sites

 

Here is a suggested solution with the use of smooth-scrollbar (see bottom of this post) @karaulovskin

 

The thing with smooth-scrolling libraries, like smooth-scrollbar (don't know about ASScroll - but from what I have read somewhere in this forum, I think it might be easier to handle) is, that they pretty much change everything about the browser-implemented scrolling.

 

That means that you really have to try understanding what they do and how they handle things - otherwise you will run into problems with scroll-based-animations over and over again with no idea how to tackle them. And most of those problems will NOT be related to GSAP or ScrollTrigger at all - just to the way the browser-scrolling is being changed by those libraries. That's why I suggested you dig into how smooth-scrollbar operates and needs to be set-up in the first place.

 

These are the Greensock-Forums after all, and although they truly are SuperHeroes over here, they can't know everything about every JS-Library or plugin out there.

 

Hope the provided example is helpful and makes things bit clearer.

Cheers.

 

 

EDIT: Had a pen up, that showed the example with smooth-scrollbar. But somehow it only worked as intended in debug view with full-window, so I took it down for now - Don't want to spread any confusion

 

EDIT 2: This should be working fine now:

See the Pen 90d2b1ad119fae2d090d050276451896 by akapowl (@akapowl) on CodePen

 

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...