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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                
	<a href="https://front.codes/" class="logo hover-target" target="_blank">
		<img src="https://assets.codepen.io/1462889/fcy.png" alt="">
	</a>

<main class="viewport">
		<div class="scroll-container">
			<div class="section over-hide full-height">	
				<div class="section-center">	
					<div class="container">
						<div class="row">
							<div class="col-12 text-center">
								<h1 class="mb-0">scroll</h1>	
							</div>
						</div>
					</div>	
				</div>			
			</div>	
			<div class="section over-hide">	
				<div class="container">
					<div class="row">
						<div class="col-lg-7 py-5">
							<div class="section over-hide img-wrap">
								<img src="https://assets.codepen.io/1462889/nature.jpg" alt="about">
								<div class="img-loader"></div>
							</div>
						</div>
					</div>
					<div class="row justify-content-end">
						<div class="col-lg-7 py-5">
							<div class="section over-hide img-wrap">
								<img src="https://assets.codepen.io/1462889/travel.jpg" alt="about">
								<div class="img-loader"></div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-lg-7 py-5">
							<div class="section over-hide img-wrap">
								<img src="https://assets.codepen.io/1462889/business.jpg" alt="about">
								<div class="img-loader"></div>
							</div>
						</div>
					</div>
					<div class="row justify-content-end pb-5">
						<div class="col-lg-7 py-5">
							<div class="section over-hide img-wrap">
								<img src="https://assets.codepen.io/1462889/animals.jpg" alt="about">
								<div class="img-loader"></div>
							</div>
						</div>
					</div>
				</div>	
			</div>	
		</div>	
	</main>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Lato:wght@700;900&display=swap');

:root {
	font-size: 20px;
	--dark-blue: #102770;
	--white-gr: #c4c3ca;
	--yellow: #ffeba7;
}
body{
	color: var(--white-gr);
	background-color: var(--dark-blue);
	overflow-x: hidden;
}
h1{
	font-family: 'Lato', sans-serif;
	font-weight: 900;
	color: var(--yellow);
	font-size: 12vw;
}
.section {
    position: relative;
	width: 100%;
	display: block;
	z-index: 2;
}
.over-hide {
    overflow: hidden;
}
.full-height {
	height: 100vh;
}
.z-bigger {
    z-index: 10 !important;
}
.section-center {
	position: absolute;
	top: 50%;
	left: 0;
	width: 100%;
	z-index: 10;
	transform: translateY(-50%);
}
main {
    position: relative;
	width: 100%;
	display: block;
	z-index: 2;
	-webkit-transition: all 200ms linear;
	transition: all 200ms linear;
}
.viewport {
  	overflow: hidden;
  	position: fixed;
  	height: 100%;
  	width: 100%;
  	top: 0;
  	left: 0;
  	right: 0;
  	bottom: 0;
}
.scroll-container {  
  	position: absolute;  
  	width: 100%;
  	top: 0;
  	left: 0;
  	z-index: 10;
	overflow: hidden;
 	transform-style: preserve-3d;
}
.img-loader {
  	position: absolute;
  	bottom: -25%;
  	left: -25%;
  	width: 150%;
  	height: 150%;
  	background-color: var(--dark-blue);
}
.img-wrap img{
    width: 100%;
    height: auto;
    display: block;
  border-radius: 6px;
}
.logo {
	position: fixed;
	bottom: 30px;
	right: 30px;
	display: block;
	z-index: 200000;
	transition: all 250ms linear;
}
.logo img {
	height: 26px;
	width: auto;
	display: block;
	mix-blend-mode: difference;
}
              
            
!

JS

              
                !function(e,n){"function"==typeof define&&define.amd?define(["ScrollMagic","TweenMax","TimelineMax"],n):"object"==typeof exports?(require("gsap"),n(require("scrollmagic"),TweenMax,TimelineMax)):n(e.ScrollMagic||e.jQuery&&e.jQuery.ScrollMagic,e.TweenMax||e.TweenLite,e.TimelineMax||e.TimelineLite)}(this,function(e,n,o){"use strict";var t=window.console||{},r=Function.prototype.bind.call(t.error||t.log||function(){},t);e||r("(animation.gsap) -> ERROR: The ScrollMagic main module could not be found. Please make sure it's loaded before this plugin or use an asynchronous loader like requirejs."),n||r("(animation.gsap) -> ERROR: TweenLite or TweenMax could not be found. Please make sure GSAP is loaded before ScrollMagic or use an asynchronous loader like requirejs."),e.Scene.addOption("tweenChanges",!1,function(e){return!!e}),e.Scene.extend(function(){var e,t=this,r=function(){t._log&&(Array.prototype.splice.call(arguments,1,0,"(animation.gsap)","->"),t._log.apply(this,arguments))};t.on("progress.plugin_gsap",function(){i()}),t.on("destroy.plugin_gsap",function(e){t.removeTween(e.reset)});var i=function(){if(e){var n=t.progress(),o=t.state();e.repeat&&-1===e.repeat()?"DURING"===o&&e.paused()?e.play():"DURING"===o||e.paused()||e.pause():n!=e.progress()&&(0===t.duration()?n>0?e.play():e.reverse():t.tweenChanges()&&e.tweenTo?e.tweenTo(n*e.duration()):e.progress(n).pause())}};t.setTween=function(a,s,l){var c;arguments.length>1&&(arguments.length<3&&(l=s,s=1),a=n.to(a,s,l));try{(c=o?new o({smoothChildTiming:!0}).add(a):a).pause()}catch(e){return r(1,"ERROR calling method 'setTween()': Supplied argument is not a valid TweenObject"),t}if(e&&t.removeTween(),e=c,a.repeat&&-1===a.repeat()&&(e.repeat(-1),e.yoyo(a.yoyo())),t.tweenChanges()&&!e.tweenTo&&r(2,"WARNING: tweenChanges will only work if the TimelineMax object is available for ScrollMagic."),e&&t.controller()&&t.triggerElement()&&t.loglevel()>=2){var u=n.getTweensOf(t.triggerElement()),p=t.controller().info("vertical");u.forEach(function(e,n){var o=e.vars.css||e.vars;if(p?void 0!==o.top||void 0!==o.bottom:void 0!==o.left||void 0!==o.right)return r(2,"WARNING: Tweening the position of the trigger element affects the scene timing and should be avoided!"),!1})}if(parseFloat(TweenLite.version)>=1.14)for(var g,d,f=e.getChildren?e.getChildren(!0,!0,!1):[e],w=function(){r(2,"WARNING: tween was overwritten by another. To learn how to avoid this issue see here: https://github.com/janpaepke/ScrollMagic/wiki/WARNING:-tween-was-overwritten-by-another")},h=0;h<f.length;h++)g=f[h],d!==w&&(d=g.vars.onOverwrite,g.vars.onOverwrite=function(){d&&d.apply(this,arguments),w.apply(this,arguments)});return r(3,"added tween"),i(),t},t.removeTween=function(n){return e&&(n&&e.progress(0).pause(),e.kill(),e=void 0,r(3,"removed tween (reset: "+(n?"true":"false")+")")),t}})});
	


var html = document.documentElement;
	var body = document.body;

	var scroller = {
	  target: document.querySelector(".scroll-container"),
	  ease: 0.09, // <= scroll speed
	  endY: 0,
	  y: 0,
	  resizeRequest: 1,
	  scrollRequest: 0,
	};

	var requestId = null;

	TweenLite.set(scroller.target, {
	  rotation: 0.01,
	  force3D: true
	});

	window.addEventListener("load", onLoad);

	function onLoad() {    
	  updateScroller();  
	  window.focus();
	  window.addEventListener("resize", onResize);
	  document.addEventListener("scroll", onScroll); 
	}

	function updateScroller() {
	  
	  var resized = scroller.resizeRequest > 0;
	    
	  if (resized) {    
	    var height = scroller.target.clientHeight;
	    body.style.height = height + "px";
	    scroller.resizeRequest = 0;
	  }
	      
	  var scrollY = window.pageYOffset || html.scrollTop || body.scrollTop || 0;

	  scroller.endY = scrollY;
	  scroller.y += (scrollY - scroller.y) * scroller.ease;

	  if (Math.abs(scrollY - scroller.y) < 0.05 || resized) {
	    scroller.y = scrollY;
	    scroller.scrollRequest = 0;
	  }
	  
	  TweenLite.set(scroller.target, { 
	    y: -scroller.y 
	  });
	  
	  requestId = scroller.scrollRequest > 0 ? requestAnimationFrame(updateScroller) : null;
	}

	function onScroll() {
	  scroller.scrollRequest++;
	  if (!requestId) {
	    requestId = requestAnimationFrame(updateScroller);
	  }
	}

	function onResize() {
	  scroller.resizeRequest++;
	  if (!requestId) {
	    requestId = requestAnimationFrame(updateScroller);
	  }
	}	


	const controller = new ScrollMagic.Controller();

	var forEach = function(array, callback, scope) {
		for (var i = 0; i < array.length; i++) {
			callback.call(scope, i, array[i]);
		}
	};

	var myNodeList = document.querySelectorAll(".img-loader");

	forEach(myNodeList, function(index, value) {
		const tween = TweenMax.to(value, 2, { borderTopLeftRadius:"100%", borderTopRightRadius:"100%", delay:0.3, height: 0, ease: Power2.easeOut });
		
		const itemScene = new ScrollMagic.Scene({
			triggerElement: value,
			triggerHook: 0.6,
			reverse: false
		})
		.setTween(tween)
		.addTo(controller);
	});
              
            
!
999px

Console