Create Horizontal smooth scroll using GSAP and reactjs

Create Horizontal smooth scroll using GSAP and Reactjs

Check Youtube video to see animation

GSAP is an industry standard JavaScript animation library from GreenSock that lets you craft high-performance animations that work in every major browser.




Create reactjs project and install gsap using npm install gsap command.

 <div ref={(el=> (body = el)} className="Headd">
    <div className="wrapper">
     <div className="panel">
      <div className="img-wrap">
       <img
        src="http://static.showit.co/800/XuvRR5ZKQ52a4R_B89WixA/59514/
        macbookpreview-8.jpg"
        alt="img-11" />
       <h2>SEO READY</h2>
      </div>
     </div>
     <div className="panel black">
      <div className="img-wrap">
       <img
        src="http://static.showit.co/800/R35-FqP9QASNbupmBSK7Iw/59514/
        macbookpreview-7.jpg"
        alt="img-12" />
       <h2>SMOOTH ANIMATION</h2>
      </div>
     </div>
     <div className="panel ">
      <div className="img-wrap">
       <img
        src="http://static.showit.co/800/KrKfX6KHTeu7iOs6wxOQMA/59514/
        macbookpreview-5.jpg"
        alt="img-13" />
       <h2>MODERN LAYOUTS</h2>
      </div>
     </div>
     <div className="panel black">
      <div className="img-wrap">
       <img
        src="http://static.showit.co/800/peoh1XDRTVat5KqUv7P6GQ/59514/
        macbookpreview-3.jpg"
        alt="img-14" />
       <h2>SEO FRIENDLY</h2>
      </div>
     </div>
     <div className="panel">
      <div className="img-wrap">
       <img
        src="http://static.showit.co/800/YyTYQlGLROOIJ5MqHIpKXQ/59514/
        macbookpreview-2.jpg"
        alt="img-15" />
       <h2>EASY TO USE</h2>
      </div>
     </div>
    </div>
   </div>

GSAP animation CODE

gsap.context();

Collects all GSAP animations and ScrollTriggers that are created within the supplied function so that you can easily revert() or kill() ALL of them at once.

GSAP Method for Animation examples already shared here, please check 
https://www.codeforinfo.com/2023/06/useful-gsap-method-to-create-gsap.html


GSAP horizontal scroll animation in reactjs


Horizontal scroll image gallery animation


Scroll animation in GSAP



Css 

.wrapper {
    width500%;
    height100vh;
    displayflex;
    flex-wrapnowrap;
  }
  .panel {
     width100%;
    height100%;
    font-weight600;
    font-size1.5em;
    colorwhite;
    positionrelative;
    box-sizingborder-box;
  }
  .panel h1 {
    font-size1.8em;
    colorwhite;
    font-weight300;
    margin0 auto;
  }
  .black {
    background-color#000;
  }
  .img-wrap{
      height:100%;
      displayflex;
      align-itemscenter;
  }

Hope you like it


Previous Post Next Post