TECHNICAL WRITING
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    ## How to build a studio Landing Page with JavaScript and GSAP’S ScrollTrigger Plugin The usage of animation raises a website's aesthetic appeal and facilitates user navigation better. The widely used GreenSock Animation platform (GSAP) is a fantastic toolset for creating animations. It offers exceptional effeciency, handles browser incompatibilities for you, and has been used in about 11,500,00 websites to date, among other fantastic qualities. Before you begin, make sure you have GSAP and ScrollTrigger on your project. If you don't have them already, you can install them using npm: ```Tag npm install gsap npm install scrolltrigger ``` ### prerequisites knowledge on Html, Css and JavaScript. ### Table of contents 1. Why use the GSAP scrollTrigger 2. Creatng the project 3. Adding content to the Html file 4. Website animation with GSAP and ScrollTrigger ### Why use the GSAP with ScrollTrigger plugin GSAP allows you to animate anything on your website that can interact with JavaScript. Moreover, there is a shortcoming that arises from GSAP'S object animations in the website. When the animations are played off-screen, you would notice that the animations already played before you scroll down to the section, preventing you from seeing the act. This led to the creation of scrollTrigger Plugin. The Plugin fixes this issue enabling you to control when the animations should be triggered. ### Creating the Landing page using scrollTrigger It would be better to familiarize with the scrollTrigger features and functions before starting to build up a Landing Page with it. Some of its feature and example can be found[here](https://codepen.io/umarmuh65823803/pen/yLpOPyN). You'll need to create a folder and name it say GSAP'S page. create the 'idex.html', 'style.css', 'index.js' and images file. ### Adding the content to the Html file Copy and add the following code to your 'index.html' file. ```html <!DOCTYPE html> <html lang="en">   <head>     <meta charset="UTF-8" />     <meta http-equiv="X-UA-Compatible" content="IE=edge" />     <meta name="viewport" content="width=device-width, initial-scale=1.0" />     <title>Document</title>     <link rel="stylesheet" href="style.css" />     <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/gsap.min.js"></script>     <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/ScrollTrigger.min.js"></script>     <script src="index.js" defer></script>   </head>   <body>     <header class="header">       <nav>         <div class="navbar">           <img src="images/logo.svg" alt="" />           <ul>             <li>               <a href="#">About</a>             </li>             <li>               <a href="#">Careers</a>             </li>             <li>               <a href="#">Events</a>             </li>             <li>               <a href="#">Products</a>             </li>             <li>               <a href="#">Supports</a>             </li>           </ul>           <img class="hamburger" src="images/icon-hamburger.svg" alt="" />         </div>         <div class="advert">           <h1>IMMERSIVE EXPERIENCES THAT DELIVER</h1>         </div>       </nav>     </header>     <section>       <div class="img-div">         <img           class="interactive-img"           src="./images/image-interactive.jpg"           alt="vr-image"         />       </div>       <div class="interactive-div">         <h3>THE LEADER IN INTERACTIVE VR</h3>         <p>           Founded in 2011, Loopstudios has been producing world-class virtual           reality projects for some of the best companies around the globe. Our           award-winning creations have transformed businesses through digital           experiences that bind to their brand.         </p>       </div>     </section>     <article>       <div class="label">         <h3>OUR CREATIONS</h3>         <button>SEE ALL</button>       </div>       <div class="photos">         <div class="box img-box1">           <img src="images/image-deep-earth.jpg" alt="" />           <p>DEEP EARTH</p>         </div>         <div class="box img-box2">           <img src="images/image-night-arcade.jpg" alt="" />           <p>NIGHT ARCADE</p>         </div>         <div class="box img-box3">           <img src="images/image-soccer-team.jpg" alt="" />           <p>SOCCER TEAM VR</p>         </div>         <div class="box img-box4">           <img src="images/image-grid.jpg" alt="" />           <p>THE GRID</p>         </div>         <div class="box img-box5">           <img src="images/image-from-above.jpg" alt="" />           <p>FROM UP ABOVE VR</p>         </div>         <div class="box img-box6">           <img src="images/image-pocket-borealis.jpg" alt="" />           <p>POCKET BOREALIS</p>         </div>         <div class="box img-box7">           <img src="images/image-curiosity.jpg" alt="" />           <p>THE CURIOSITY</p>         </div>         <div class="box img-box8">           <img src="images/image-fisheye.jpg" alt="" />           <p>MAKE IT FISHEYE</p>         </div>       </div>     </article>     <div class="virtual-reality">       <img         class="layer"         src="https://cdn.pixabay.com/photo/2021/11/22/00/02/interior-design-6815493__340.jpg"         alt=""       />       <img         class="layer"         src="https://cdn.pixabay.com/photo/2022/03/03/21/30/vr-7046094__340.jpg"         alt=""       />       <img         class="layer"         src="https://cdn.pixabay.com/photo/2021/12/24/13/01/vr-6891052__340.jpg"         alt=""       />       <img         class="layer"         src="https://cdn.pixabay.com/photo/2021/12/26/03/48/earth-6894160__340.jpg"         alt=""       />       <img         class="layer"         src="https://media.istockphoto.com/vectors/astronaut-looking-on-earth-from-alien-planet-vector-id1324630423?k=20&m=1324630423&s=612x612&w=0&h=b1-F0bexQ28zFZEl4igb1Nlda6zkmjDu_goGv3dg-Xc="         alt=""       />     </div>     <footer>       <div class="logos">         <img src="images/logo.svg" alt="" />         <div class="icons">           <img src="images/icon-facebook.svg" alt="" />           <img src="images/icon-twitter.svg" alt="" />           <img src="images/icon-pinterest.svg" alt="" />           <img src="images/icon-instagram.svg" alt="" />         </div>       </div>       <div class="bottom">         <ul id="footer-list">           <li>             <a href="#">About</a>           </li>           <li>             <a href="#">Careers</a>           </li>           <li>             <a href="#">Events</a>           </li>           <li>             <a href="#">Products</a>           </li>           <li>             <a href="#">Support</a>           </li>         </ul>         <p>&copy 2021 Loopstudios. All rights reserved.</p>       </div>     </footer>   </body> </html> ``` #### Landing page Stylesheet This will style the html page for it to be applealing. ```css @import url("https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@100;200;300;400&display=swap"); @import url("https://fonts.googleapis.com/css2?family=Alata&display=swap"); * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: "Alata", sans-serif; color: blue; overflow-x: hidden; } h1 { color: #fff; font-size: 4rem; font-weight: 100; } p { font-size: 15px; } header { background-image: url("./images/image-hero.jpg"); max-width: 100%; height: 80vh; } .virtual-reality { justify-content: center; align-items: center; } .virtual-reality img { display: block; margin: 2rem auto; height: 80vh; width: 80vw; } nav { display: flex; flex-wrap: wrap; width: 85%; margin: 0rem auto; } .navbar { display: flex; width: 100%; justify-content: space-between; padding: 3rem 0; } .hamburger { display: none; } h3 { color: #fff; } ul { display: flex; gap: 2rem; } li { list-style-type: none; } a { font-family: inherit; text-decoration: none; color: #fff; font-size: 15px; padding-bottom: 0.7rem; } a:hover { border-bottom: 3px solid #fff; } a.active { border-bottom: 3px solid #fff; } .advert { width: 50%; display: flex; margin-top: 3rem; padding: 1rem; text-align: left; flex-wrap: wrap; border: 1px solid #fff; } .advert h1 { max-width: 100%; } section { width: 85%; position: relative; display: flex; margin: 3.5rem auto 7rem auto; justify-content: space-between; } .interactive-img { display: block; } .interactive-div { position: absolute; left: 55%; background: #fff; bottom: 0; padding: 4rem 0 0 4rem; max-width: 600px; } h3 { letter-spacing: 3px; font-weight: 100; margin-bottom: 1rem; color: #000; font-size: 3rem; } section p { font-size: 15px; line-height: 1.5; color: hsl(0, 0%, 55%); } article { width: 85%; margin: 1rem auto; } .img-div { /* visibility: hidden; */ overflow: hidden; } .img-div img { transform-origin: left; } img { cursor: pointer; max-width: 100%; } .label { display: flex; margin-bottom: 3rem; justify-content: space-between; } .label h3 { color: black; font-size: 2.5rem; } article button { cursor: pointer; border: none; padding: 0.1rem 3rem; background-color: #000; color: #fff; letter-spacing: 2px; } .photos { display: flex; flex-wrap: wrap; width: 100%; justify-content: space-between; } .photos img { margin-bottom: 1rem; } .photos img:hover { opacity: 0.5; } .img-box1, .img-box2, .img-box3, .img-box4, .img-box5, .img-box6, .img-box7, .img-box8 { position: relative; } .img-box1 p, .img-box2 p, .img-box3 p, .img-box4 p, .img-box5 p, .img-box6 p, .img-box7 p, .img-box8 p { position: absolute; font-weight: 100; padding: 5px; left: 1rem; width: 60%; font-size: 2rem; bottom: 2.5rem; color: #fff; } footer { background-color: #000; padding: 2rem 0; margin-top: 4rem; } .logos { width: 85%; margin: 1rem auto 1rem auto; display: flex; justify-content: space-between; } .logos h3 { color: #fff; align-items: center; } .icons img { margin-left: 0.5rem; padding-bottom: 5px; } .icons img:hover { border-bottom: 3px solid #fff; } .bottom { width: 85%; justify-content: space-between; display: flex; margin: 0 auto; } footer p { color: hsl(0, 0%, 55%); } #footer-list { display: flex; justify-content: space-between; } @media screen and (max-width: 600px) { nav { width: 100%; } .navbar { margin: 0 1rem; } .hamburger { display: flex; } .advert { width: 85%; margin: 0 auto; justify-content: center; } header { background-size: cover; } .navbar ul { display: none; } .interactive-div { width: 90%; text-align: center; position: relative; left: 0; padding-left: 0; padding-right: 0; margin: 0 auto; } .label { width: 100%; flex-direction: column; justify-content: center; align-items: center; text-align: center; } .label h3 { margin: 0 auto; } section { width: 95%; flex-direction: column; } article { width: 95%; justify-content: center; } .interactive-img { width: 100%; } .photos { margin: 0 auto; flex-direction: column; width: 100%; } .virtual-reality { margin-bottom: 2rem; } .virtual-reality img { height: 50vh; } .img-box1 img, .img-box2 img, .img-box3 img, .img-box4 img, .img-box5 img, .img-box6 img, .img-box7 img, .img-box8 img { max-width: 100%; width: 100%; height: 50vh; margin: 1rem 0; } .bottom { flex-direction: column; align-items: center; } footer { position: sticky; height: 35vh; } #footer-list { flex-direction: column; margin: 0 auto; gap: 0.5rem; } .logos { align-items: center; justify-content: center; flex-direction: column; margin: 0.2rem auto; } } @media screen and (max-width: 900px) { .advert h1 { font-size: 2.5rem; } } ``` ### Animating the website with GSAP and ScrollTrigger <em>Note that the CDNs for GSAP and ScrollTrigger are to be added using the script tag in the 'head' of the HTML file. It would be impossible to create animations and trigger them on the scroll without initialization. <em> ```javascript //Registering the scrollTrigger plugin gsap.registerPlugin(ScrollTrigger); //Animating the advert div with GSAP gsap.fromTo( ".advert", { xPercent: 30 }, { duration: 3, xPercent: 0, ease: "bounce" } ); //Animating the Section elements gsap .timeline() .from(".img-div img", { xPercent: -100, duration: 1, scrollTrigger: { trigger: ".img-div", start: "top center", end: "bottom center", scrub: true, }, }) .fromTo( ".interactive-div", { yPercent: -50, scale: 0.5 }, { opacity: 1, yPercent: 0, scale: 1, scrollTrigger: { trigger: ".interactive-div", start: "top center", end: "bottom center", scrub: true, }, } ); ``` From the above code snippet, the `scrollTrigger` plugin was firt registered to enable animations on the scroll. A simple animation is created for the `.advert` class using `gsap.fromTo` . The animation starts near the middle of the page `xPercent: 30` to the left `xPercent: 0`, bounces `ease: bounce` when it reaches the end. The entire animation takes place in 3 seconds `duration: 3`. Next, is a `timeline` created to control the following tweens as a whole. The `img-div` image is animated from the left of its container using `xPercent:-100`. This doesn't yet animate on scroll, so the scrollTrigger property is added and the `trigger` targets the `img-div` class, the image is set to begin animating when the top of the image is scrolled to the center of the page and should end when the bottom reaches the center. The scrub is added to synchronize the progress of themhe animation on scroll. The same process is repeated for the `interactive-div` which contains text, the element is animated from the middle(50%) of its container to the bottom(0%), its `scale` increases from `0.5` to `1.0` and it takes the scrub property to ensure a smooth animation. ## Conclusion Congratulations you have learnt how to build and animate any website. GSAP and scrollTrigger are the way to create a landing page.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully