VikLiegostaiev / react-page-scroller

Simple React component for smoothy full-page scolling using CSS animations. React Page Scroller
https://github.com/VikLiegostaiev/react-page-scroller
MIT License
415 stars 85 forks source link

Call a method before scrolling #5

Closed Thurstonjhon closed 6 years ago

Thurstonjhon commented 6 years ago

Hi im trying to implement this with gsap, is there a way i can play tween before scrolling to a page? an example i think is an exit animation before scrolling to another component. Thanks!

VikLiegostaiev commented 6 years ago

@Thurstonjhon Hi, I haven't used gsap, you want me to implement this method or you want just do it by yourself with my hint? Because I don't have such feature in my component now.

Thurstonjhon commented 6 years ago

Hi Thanks for the response, Probably wanted to do it myself with your hint.

VikLiegostaiev commented 6 years ago

@Thurstonjhon have one idea. Every time before you call scrollWindowDown or scrollWindowUp you can check for a callback in props. e.g. :

if (this.props.onBeforeScrollDown) {
            this.props.onBeforeScrollDown(this.scrollWindowDown);   //here we pass this.scrollWindowDown as callback to onBeforeScrollDown, 
                                                                    // so you can easily continue library work after doing some effects 
                                                                    // on your side :-)
} else {
            this.scrollWindowDown();
}

you can do such for scrollWindowUp as well or you can pass common callback e.g. onBeforeScroll.

I hope this can help you.

Thurstonjhon commented 6 years ago

@VikLiegostaiev Thanks!, i got it working great library by the way very helpful!