Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="container">
Package	com.greensock.plugins
Class	public class ScrollToPlugin
Inheritance	ScrollToPlugin   TweenPlugin  Object
Allows TweenLite and TweenMax to animate the scroll position of either the window (like doing window.scrollTo(x, y)) or a <div> DOM element's content (like doing myDiv.scrollTop = y; myDiv.scrollLeft = x;). To scroll the window to a particular position, use the window as the target of the tween like this:
//scroll to 400 pixels down from the top
TweenLite.to(window, 2, {scrollTo:{y:400}, ease:Power2.easeOut});
Or to tween the content of a div, make sure you've set the overflow:scroll on the div and then do this:

//scroll to 250 pixels down from the top of the content in the div
TweenLite.to(myDiv, 2, {scrollTo:{y:250}, ease:Power2.easeOut});
You can define an x or y value or both (to scroll on both the x- and y-axis). For example, to scroll to 400 pixels from the top and 200 pixels from the left, do this:

TweenLite.to(myDiv, 2, {scrollTo:{y:400, x:200}, ease:Power2.easeOut});
The ScrollToPlugin will automatically sense if the scroll position was changed outside of itself (like if the user manually started dragging the scrollbar mid-tween) and cancel that portion of the tween. It won't kill the entire tween - just the scrolling portion of the tween. That means, for example, that the tween's onComplete would still fire at the end of the tween. If, however, you'd like to kill the entire tween if another force changes the scroll position, set autoKill:true inside the scrollTo object, like:

TweenLite.to(myDiv, 2, {scrollTo:{y:400, autoKill:true}, ease:Power2.easeOut});
To scroll to the maximum scroll position, use the string "max" as the value, like this:
TweenLite.to(myDiv, 2, {scrollTo:{y:"max"}});
If you don't wrap the value in an object, it will assume you want to scroll in the "y" direction, so these two lines are funtionally equivalent:
TweenLite.to(myDiv, 2, {scrollTo:{y:"max"}});
TweenLite.to(myDiv, 2, {scrollTo:"max"});
Copyright 2008-2013, GreenSock. All rights reserved. This work is subject to the terms in https://www.greensock.com/terms_of_use.html or for Club GreenSock members, the software agreement that was issued with the membership.
  <div class="measure"></div>
</div>
              
            
!

CSS

              
                #container{
  position:relative;
  top:80px;
  width:350px;
  height:300px;
  overflow-y:scroll;
}

.measure{
  position:absolute;
  top:0px;
  width:335px;
  height:250px;
  background-color:rgba(255, 0, 0, 0.2);
}

              
            
!

JS

              
                TweenMax.to("#container", 2, {scrollTo:{y:250}, repeat:6, repeatDelay:0.4, yoyo:true});
              
            
!
999px

Console