Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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="smooth-wrapper">
  <div id="smooth-content">
<header>
	<h1>Header</h1>
  <a href="#section1">section 1</a>
</header>
<section id="section1" class="section_computer" >
	<div class="no-container relative">
		<div class="colm_2">
			<div class="col">
				<div class="section_computer_wrap">
				<div class="section_computer_content">
					<div class="section_computer_panel panel-1">
						<h3>111 IPSUM DOLOR SIT AMET CONSECTETUR ADIPISICING, ELIT. </h3>
						<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Eos excepturi, ipsam eum aliquam, facere non, dolores natus, deserunt iusto pariatur commodi sed quia quam animi rerum officiis ducimus dignissimos nulla!</p>
					</div>

					<div class="section_computer_panel panel-2">
						<h3>222 IPSUM DOLOR SIT AMET CONSECTETUR ADIPISICING, ELIT. </h3>
						<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Eos excepturi, ipsam eum aliquam, facere non, dolores natus, deserunt iusto pariatur commodi sed quia quam animi rerum officiis ducimus dignissimos nulla!</p>
					</div>

					<div class="section_computer_panel panel-3">
						<h3>333 IPSUM DOLOR SIT AMET CONSECTETUR ADIPISICING, ELIT. </h3>
						<p>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Eos excepturi, ipsam eum aliquam, facere non, dolores natus, deserunt iusto pariatur commodi sed quia quam animi rerum officiis ducimus dignissimos nulla!</p>
					</div>
				</div>
				</div>
			</div>
			<div class="col">
				<div class="clear section_computer_video">
					 <video src="https://assets.codepen.io/39255/output_960.mp4" playsinline="true" webkit-playsinline="true" preload="auto" muted="muted" class="video-background"></video> 
					
</div>
</div>

</div>
</div>
</section> 
<Footer>
	<h1>Footer</h1>
</Footer>
    </div>
</div>
              
            
!

CSS

              
                body,
html {
  margin: 0;
}
header,footer{
  height:100vh;
}

.colm_2:before,
.colm_2:after
{
  content: '';
  display: table;
}

.colm_2{
   width: 100%;
}

@media only screen and (min-width: 768px) {
  .colm_2 .col {
    width: 49.95%;
  }
  .colm_2 .col:nth-child(1n) {
    float: left;
    margin-right: 0px;
    clear: none;
  }
  .colm_2 .col:last-child {
    margin-right: 0;
  }
  .colm_2 .col:nth-child(2n) {
    margin-right: 0;
    float: right;
  }
  .colm_2 .col:nth-child(2n + 1) {
    clear: both;
  }
}

.section_computer {
  width: 100%;
  background-color: #21748f;
  color: #ffc0ce;
  height: 100vh;
  overflow: hidden;
}
.section_computer_wrap {
  position: relative;
  position: relative;
  width: 100%;
  height: 100vh;
}
.section_computer_wrap > * {
  position: absolute;
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
          transform: translate(-50%, -50%);
}
.section_computer_content {
  width: calc(66.6% - 10px);
  height: 100vh;
}
.section_computer_content:nth-child(1n) {
  float: left;
  margin-right: 30px;
  clear: none;
}
.section_computer_content:last-child {
  margin-right: 0;
}
.section_computer_content:nth-child(6n) {
  margin-right: 0;
  float: right;
}
.section_computer_content:nth-child(6n + 1) {
  clear: both;
}
.section_computer_panel {
  height: 100%;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  position: absolute;

}
.section_computer .panel-2,
.section_computer .panel-3{
  opacity: 0;
}

.section_computer_video {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100vh;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
}
.section_computer_video video {
  width: 100%;
}
              
            
!

JS

              
                console.clear();

gsap.registerPlugin(ScrollTrigger, ScrollSmoother,ScrollToPlugin);

  let smoother = ScrollSmoother.create({
  smooth: 2,   // seconds it takes to "catch up" to native scroll position
  effects: true, // look for data-speed and data-lag attributes on elements and animate accordingly
  smoothTouch: 0.1,
});

    var scrollComputer = document.querySelector("header a");
  scrollComputer.onclick = function() {
   console.log("scrollComputer");
   smoother.scrollTo("#computer", true, "top -250px");
 }


const video = document.querySelector(".video-background");
 

let tl = gsap.timeline({
  defaults: { duration: 1 },
  scrollTrigger: {
   trigger: ".section_computer",
   scrub: true,
   //markers: true,
   pin: true,
   start: () => "top top",
   end: () => "+=" + window.innerHeight,
   invalidateOnRefresh: true,
 }
});


tl.add(videoScrub(video, {
  duration: 3.75,
  paused: false
}))

tl.to(".panel-1", {
 keyframes: [
  {yPercent:0},
  {yPercent:-100, opacity:0}
 ]
},1);
  tl.to(".panel-2", {
 keyframes: [
  {xPercent:100, yPercent:100, opacity:0  },
  {xPercent:10, yPercent:80, opacity:1  },
  {xPercent:0, yPercent:0},
  {xPercent:0, yPercent:0 , delay:3 },
  {xPercent:0, yPercent:-100,opacity:0 ,duration:1 }
 ],

},"-=3.2");

  tl.to(".panel-3", {
 keyframes: [
 {xPercent:100, yPercent:100, opacity:0  },
  {xPercent:10, yPercent:80, opacity:1  },
  {xPercent:0, yPercent:0},
  {xPercent:0, yPercent:0 , delay:3 },
  {xPercent:0, yPercent:-100,opacity:0,duration:1  }
 ],
 ease: 'expo.inOut'

},"-=2.2");
console.log("tl duration", tl.duration())
tl.getChildren().forEach(c => console.log("animation", c.startTime(), c.duration()))

function videoScrub(video, vars) {
  video = gsap.utils.toArray(video)[0]; // in case selector text is fed in.
  let once = (el, event, fn) => {
        let onceFn = function () {
          el.removeEventListener(event, onceFn);
          fn.apply(this, arguments);
        };
        el.addEventListener(event, onceFn);
        return onceFn;
      },
      prepFunc = () => { video.play(); video.pause(); },
      prep = () => once(document.documentElement, "touchstart", prepFunc),
      src = video.currentSrc || video.src,
      tween = gsap.fromTo(video, {currentTime: 0}, {paused: true, immediateRender: false, currentTime: video.duration || 1, ease: "none", ...vars}),
      resetTime = () => (tween.vars.currentTime = video.duration || 1) && tween.invalidate();
  // once(video, "loadedmetadata", resetTime);
  prep();
  video.readyState ? resetTime() : once(video, "loadedmetadata", resetTime);
  return tween;
}

              
            
!
999px

Console