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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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

              
                <div class="wrapper"> 
<div>
  <div class ="divider">
    <p style="font-size:5rem">SCROLL DOWN </p>
</div>
<div>
  <div class ="doAnimacji">
    <div class ="elementyAnimacja"></div>
    <div class ="elementyAnimacja"></div>
    <div class ="elementyAnimacja"></div>
</div>
  <div class ="doAnimacji">
    <div class ="elementyAnimacja"></div>
    <div class ="elementyAnimacja"></div>
    <div class ="elementyAnimacja"></div>
</div>
  
</div>
  </div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Signika+Negative:300,400&display=swap');

body { 
  font-family: "Signika Negative", sans-serif; 
  font-weight: 300;
  margin: 0;
  padding: 0 20px;
}
.wrapper{
  width:90%;
  margin:auto
}
.divider{
  width:100%;
  height:14rem;
   background-color:grey;
  margin:2rem;
}

.doAnimacji{
  width:100%;
    background-color:grey;
  margin:2rem;
  display:flex;
  justify-content:center;
  margin:1rem;
}

.elementyAnimacja{
  width:7rem;
  height:7rem;
  background-color:yellow;
   margin:1rem;
  
}


              
            
!

JS

              
                var testTimeline = gsap.timeline({}); //timeline to be used for the elements
testTimeline.pause(); // pause the timeline as default
var doAnimacji = gsap.utils.toArray(".doAnimacji"); //elements-children of the parents
var elementyAnimacja =  document.querySelectorAll(".elementyAnimacja"); // tha parents

///Timeline definition
testTimeline.add("start",0);
testTimeline.set (elementyAnimacja, {y:50,autoAlpha:0, duration:.8, ease: "power2.inOut"});
testTimeline.to (elementyAnimacja, {y:0, autoAlpha:1, duration:.8, stagger: .3,ease: "power2.inOut"});
testTimeline.add("middle",">");
testTimeline.to (elementyAnimacja, {y:-50,autoAlpha:0, duration:.8,ease: "power2.inOut"});
testTimeline.add("end",">");



gsap.utils.toArray(".doAnimacji").forEach((blok)=> { // for each Parent
var elementyAnimacjaIns = blok.querySelectorAll(".elementyAnimacja"); //every child of the parent
   console.log(elementyAnimacjaIns);
            ScrollTrigger.create({elementyAnimacjaIns, //create a scrolltrigger for each child
            trigger:blok,
            start: 'top 80%',
            end: 'top-=70 20%',
            onEnter: elementEnter,
            onEnterBack: elementEnterBack,
            onLeave : elementLeave,
            onLeaveBack : elementLeaveBack,
            markers: true,
            });
            console.log("EACH TIME");
 
});
// functions to be fired by the scroltriggers
function elementEnter (){ // ON ENTER
        console.log("ENTER")
        testTimeline.tweenFromTo("start","middle");
    };
    function elementLeave (){ // ON ENTER
        console.log("LEAVE")
        testTimeline.tweenFromTo("middle","end");
    };

     function elementLeaveBack (){ // ON ENTER
        console.log("LEAVE BACK")
      testTimeline.tweenFromTo("middle","start");
    };

     function elementEnterBack (){ // ON ENTER
        console.log("ENTER BACK")
       testTimeline.tweenFromTo("end","middle");
    };



              
            
!
999px

Console