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

              
                
<h2>Just scroll ...</h2>


<div class="wrapper02">
  <div class="boxes02">
    <div class="box02 ten">GreenSock</div>
    <div class="box02 one">Nice Tool</div>
    <div class="box02 two">GreenSock</div>
    <div class="box02 three">Animate everything</div>
    <div class="box02 four">Fast & easy</div>
    <div class="box02 one">GreenSock</div>
    <div class="box02 two">The best Tool</div>
  
</div>
</div>
              
            
!

CSS

              
                body {
  background:grey;
  font-family:Asap, sans-serif;
  height:10000px;
}


h2{
  position:fixed;
  width:100%;
  color: #b5b5b5;
  text-align: center;
}

.wrapper02{
  position:fixed;
  width:150%;
  height:50px;
  left:50%;
  top:50%;
  background:grey;
  overflow:hidden;
}
.wrapper02 .box02{
  width: 250px;
  height:50px;
  position:absolute;
  background:grey;
  color:black;
  font-size:40px;
  font-weight:600;
  line-height:50px;
  text-align:center;

}
.wrapper02 .boxes02 {
  position:relative;
  left:-250px;
}
              
            
!

JS

              
                
TweenMax.set('.wrapper02',{xPercent:-50,yPercent:-50})

//initially position each box in a row
TweenMax.set(".box02", {
  x:function(i) {
    return i * 250;
  }
});

var time = 30;

var action = new TimelineMax()

.to(".box02", time, {
  ease: Linear.easeNone,
  x: "+=1750", //move each box xxx px to right
                // xxx = box width * number of boxes
  modifiers: {
    x: function(x) {
      return x % 1750; //force x value to be between 0 and xxx using modulus
    }                   
  },
  repeat:-1,
});

// =======================
// var checkScrollSpeed = (function(settings){
//     settings = settings || {};
  
//     var lastPos, newPos, timer, delta, 
//         delay = settings.delay || 20; // in "ms" (higher means lower fidelity )
  
//     function clear() {
//       lastPos = null;
//       delta = 0;
//     }
  
//     clear();
    
//     return function(){
//       newPos = window.scrollY;
//       if ( lastPos != null){ // && newPos < maxScroll 
//         delta = newPos -  lastPos;
//       }
//       lastPos = newPos;
//       clearTimeout(timer);
//       timer = setTimeout(clear, delay);
//       return delta;
//     };
// })();


// var speed = checkScrollSpeed();
// // listen to "scroll" event
// window.onscroll = function(){
//   speed = checkScrollSpeed();
//   console.log("speed:", speed);
// action.timeScale(speed/10).play();
// };

$(window).scroll(function() {
    var displacement = $(window).scrollTop();
  console.log("displacement: ", displacement);
    var factor = 1 + displacement/500;
    action.pause().timeScale(factor).play();
});

var scrollStop = function (callback) {

	// Make sure a valid callback was provided
	if (!callback || typeof callback !== 'function') return;

	// Setup scrolling variable
	var isScrolling;

	// Listen for scroll events
	window.addEventListener('scroll', function (event) {

		// Clear our timeout throughout the scroll
		window.clearTimeout(isScrolling);

		// Set a timeout to run after scrolling ends
		isScrolling = setTimeout(function() {

			// Run the callback
			callback();

		}, 10);

	}, false);

};

scrollStop(function () {
    action.timeScale(1).play();
});

              
            
!
999px

Console