The jQuery plugin for supercool scroll animation
powered by Greensock
created by John Polacek
with help from Jan Paepke
NOTE: SuperScrollorama is no longer under active development. ScrollMagic is the new hotness!
Get ScrollMagic
Check out these great websites to see SuperScrollorama in action
Need help building your website? Contact us.
Please note, this is a powerful tool, and with great power comes great responsibility.
Use wisely. A little subtlety can go a long way.
★ ★ ★
SuperScrollorama is powered by TweenMax and the Greensock Tweening Engine. Go to greensock.com for documentation on how to use it. Why Greensock/TweenMax? Great performance, ease-of-use, expandibility and basically because it is awesome.
First, link to the jQuery CDN and then embed TweenMax.js and SuperScrollorama. Next, start up SuperScrollorama. Think of it as a controller for animation. You add tweens and timelines to it, targeting when an element appears in the viewport or at a specific scroll point.
When initializing SuperScrollorama there are several options you might want to change.
Example
$(document).ready(function() { var controller = $.superscrollorama({ triggerAtCenter: false, playoutAnimations: true }); });
★ ★ ★
Use the addTween method to build your scroll animations.
In the example below, the animation fades in when scrolled into view.
controller.addTween('#fade', TweenMax.from($('#fade'), .5, {css:{opacity:0}}));
★ ★ ★
The default duration is 0, which means the tween plays through completely when its scroll point is reached. You can add a duration which will instead sync the tween progress to the scrollbar position. Instead of one tween, you can create a timeline of multiple tweens.
If you use the TweenMax or TimelineMax option {repeat: -1} the animation will loop indefinetly for the set duration.
// parallax example controller.addTween( '#examples-parallax', (new TimelineLite()) .append([ TweenMax.fromTo($('#parallax-it-left'), 1, {css:{top: 200}, immediateRender:true}, {css:{top: -600}}), TweenMax.fromTo($('#parallax-it-right'), 1, {css:{top: 500}, immediateRender:true}, {css:{top: -1250}}) ]), 1000 // scroll duration of tween );
★ ★ ★
The 4th parameter is offset, which you can use to adjust the scroll point at which the animation is triggered.
controller.addTween('#fade', TweenMax.from($('#fade'),.5,{ css:{opacity:0}}), 0, // scroll duration of tween (0 means autoplay) 200); // offset the start of the tween by 200 pixels
★ ★ ★
The 5th parameter is reverse, which you can use to disable reverse animation.
controller.addTween('#fade', TweenMax.from($('#fade'),.5,{ css:{opacity:0}}), 200, false); // prevent backwards animation of the element
★ ★ ★
Pass in a function to the tween for when the animation is complete.
controller.addTween('#fade', TweenMax.from($('#fade'),.5,{ css:{opacity:0}, onComplete: function(){alert('test')} }));
★ ★ ★
You can remove any previously added Tweens using the removeTween method.
In the example below, all tweens from the "#fade" element are removed and reset.
controller.removeTween('#fade');
★ ★ ★
You can use the pin method to pin an element, do a series of animations and then unpin it.
The callback functions will be called with a boolean parameter, true if triggered at end (bottom) of pin, false, if triggered at the beginning (top point).
Example:
controller.pin($('#examples-2'), 3000, { anim: (new TimelineLite()) .append( TweenMax.fromTo($('#move-it'), .5, {css:{left: -200, top: 500}, immediateRender:true}, {css:{top: -400}}) ) .append( TweenMax.to($('#move-it'), .5, {css:{left: 200}}) ) .append( TweenMax.to($('#move-it'), .5, {css:{top: -200}}) ) .append( TweenMax.to($('#move-it'), .5, {css:{left: 0}}) ) });
★ ★ ★
You can use the updatePin method if you want to change options for pinned elements at runtime. For example when the window size or the size of your pin Item have changed. It Expects the same parameters as the .pin method, except all but the element is optional.
Example:
controller.updatePin($('#examples-2'), null, { offset: 200 });
★ ★ ★
You can remove any previously added Pins using the removePin method.
In the example below, the pin is removed, but not reset.
reset=false will also mean that if you call it during pin, the element will stay pinned.
controller.removePin('#examples-2', false);
★ ★ ★
Sometimes you might want to tell SuperScrollorama to update all elements, for example when the window is resized. Here the method triggerCheckAnim comes in handy.
Example:
$(window).resize(function () { controller.triggerCheckAnim(); });
★ ★ ★
If you go the extra mile to make your SuperScrollorama application accessible to mobile users you'll need the method setScrollContainerOffset. For more details see simpledemo_mobile.html
Example:
controller.setScrollContainerOffset(0, 200);
SuperScrollorama by Chicago Web Developer John Polacek
with Jan Paepke
Greensock Tweening Engine & TweenMax by Greensock
Luckiest Guy Font by Astigmatic Fonts
John Polacek works at Gesture, a mobile bidding and fundraising technology company that helps charities raise more money.