<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="lionel.css">
<title>Document</title>
</head>
<body>
<div id="smooth-wrapper">
<div id="smooth-content">
<div class="description">
<div>
<h1>Horizontal "<code>containerAnimation</code>"</h1>
<p>Scroll this page vertically and you'll see a horizontal fake-scrolling section where a container is
animated on the x-axis using a ScrollTrigger animation. With <code>containerAnimation</code> you can trigger
animations when certain elements <i>inside</i> that container enter the viewport horizontally! It's like a
ScrollTrigger inside of a ScrollTrigger. 🤯
</p>
</div>
</div>
<div class="container">
<section class="panel blue">
<p>Scroll down to animate horizontally Blue</p>
<div class="box-1 box">box-1</div>
</section>
<section class="panel orange">
<p>Scroll down to animate horizontally Red</p>
<div class="box-2 box">box-2</div>
</section>
<section class="panel red">
<p>Scroll down to animate horizontally Blue</p>
<div class="box-3 box">box-3</div>
</section>
<section class="panel purple">
<p>Scroll down to animate horizontally Red</p>
<div class="box-4 box">box-4</div>
</section>
<section class="panel green">
<p>Scroll down to animate horizontally Blue</p>
<div class="box-5 box">box-5</div>
</section>
</div>
<div class="final">
<div>
<h1>Wasn't that fun?</h1>
<p>Here are a few caveats to keep in mind:</p>
<ul>
<li>The fake-scrolling animation (just the part that's moving the container horizontally) must have no
easing (<code>ease: "none"</code>).</li>
<li>Pinning and snapping won't work on ScrollTriggers with a <code>containerAnimation</code>.</li>
<li>The mapping of scroll position trigger points are based on the trigger element itself not being animated
horizontally (inside the container). If you need to animate the trigger, you can either wrap it in a
<div> and use that as the trigger instead or just factor the trigger's movement into your end
position. For example, if you animate it left 100px, make the <code>end</code> 100px further to the left.
</li>
<li>Requires ScrollTrigger 3.8.0 or later</li>
</ul>
</div>
</div>
</div>
</div>
<script src="https://assets.codepen.io/16327/gsap-latest-beta.min.js?r=v3.11.3"></script>
<script src="https://assets.codepen.io/16327/ScrollTrigger.min.js"></script>
<script src="https://unpkg.com/gsap/dist/Observer.min.js"></script>
<script src="ScrollSmoother.min.js"></script>
<script src="lionel.js"></script>
</body>
</html>