Jump to content
Search Community

analyticaprojects.com How the heck?

rivertim test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi there

 

This analyticaprojects.com site kicked off my interest in WebGL and canvas ; been crash reading a lot of stuff over the past few days that has led me to GreenSock :) but I'm not understanding how the heck it's all working – especially how the scroll bar is controlling the state of the text animation? Could someone kindly enlighten me?

 

Many thanks

 

Tim

 

 

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

The trick to scroll-driven animations is first to understand that every tween or timeline has a progress() which returns or sets a number between 0 and 1 that represents how complete the animation is.

 

progress:0 = not complete at all

progress: 0.5 = half

progress:1 = totally complete

 

You can set the progress of an animation using

 

myAnimation.progress(0.5) // make animation jump its halfway point.

 

You can pass in any value between 0 and 1 that you want and take it from anywhere: the mouse position, a slider component, scroll position or anything you can think of

 

this demo shows how you can set the progress() of an animation using an HTML5 input slider:

 

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

 

 

 

Here's an old demo using a lot of jQuery to change the progress based on scroll position

 

 

 

See the Pen mbrqt?editors=0010 by adrianparr (@adrianparr) on CodePen

 

 

Here's a demo from @OSUblake

 

 

See the Pen 46295694a457cc0c61f32a8153e26639 by osublake (@osublake) on CodePen

 

Using canvas the same concepts can apply. Create a timeline full of a bunch of animations. As the user scrolls generate a number that gets normalized and passed into that animation's progress()

 

 

  • Like 3
Link to comment
Share on other sites

Here's an example that actually uses canvas. Nothing too exciting. I was just showing somebody how to do it. If you inspect the canvas in your dev tools, you'll see that it isn't scrolling. Its position is fixed, and is the size of the screen. There's another element that I set the height on to give it scrollbars, which will also allow it to work with touch.

 

See the Pen xEaRpr by osublake (@osublake) on CodePen

 

 

 

  • Like 3
Link to comment
Share on other sites

Thanks for the welcome @Carl @OSUblake and great info with examples.  So, I start to understand that the scrollbar sends its position to the timeline to control its animation, but where does the timeline/tween live? On my example site where does that large block text 'live'? I can't see it in any of the source. And how is it authored? Is there a tool like Flash (old school) with a timeline that you export to code? I think I'm not grasping something basic…

 

Thanks.

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...