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

              
                <section id="hero" class="hero-anim">
    <div class="container-fluid">
        <div class="row justify-content-center align-items-center">

            <div id="hero-content-01" class="col-md-8 col-lg-6 hero-content">
                <h1 class="title">Some Title <span>subtitle</span></h1>
              <p id="posLeftStart">Text column left position before <strong>scene01in</strong>: <span>0</span></p>
              
              <p id="posLeftEnd">Text column left position before <strong>scene01out</strong>: <span>0</span></p>
              
              <p><em>Why is end left position not being reset by clearProps?</em></p>
              <button id="restart">restart</button>
            </div><!-- .col -->

           <div id="hero-imgCol-01" class="d-none d-md-block col-md-4 order-md-first hero-imgCol align-self-end">
                <img class="img-fluid" alt="fpo" src="http://place-hold.it/390x435" />
           </div>

        </div><!-- .row -->
      
    </div><!-- .container-fluid -->
</section><!-- /.hero -->
              
            
!

CSS

              
                /* give row some bg color */
.row 
{
  background: pink;
}
              
            
!

JS

              
                $(document).ready(function($)
{
    // ==== Master Timeline =========
    var master = new TimelineMax({ repeat:0 });

    TweenLite.defaultEase = Power4.easeOut;
  
  // element references
    var $hero = $("#hero");
    var $heroRow = $hero.find(".row");
    var $heroContent01 = $hero.find("#hero-content-01");
    var $heroImg01 = $hero.find("#hero-imgCol-01");
  
  
    function scene01in() 
    {
        var tl = new TimelineMax({id:"heroScene01in", onComplete:data});

        var heroContentLeft01inStart = $heroContent01.position().left;
        
        // output above
        $("#posLeftStart span").html(heroContentLeft01inStart);

        tl.set($heroContent01, {visibility:"visible", transformOrigin:"top left", force3D:true})
          .set($heroImg01, {visibility:"visible", transformOrigin:"top left", force3D:true})
        
        // move content in from right
        .from($heroContent01, 2.0, {left:"100%", xPercent:0, clearProps:"transform, left"})

        // move img in from right
        .from($heroImg01, 2.0, {left:"100%", xPercent:0}, "-=1.5" );
      
        function data()
        {
              var heroContentLeft01inEnd = $heroContent01.position().left;

              // output above
              $("#posLeftEnd span").html(heroContentLeft01inEnd); 
        }

        return tl;
    }
  
    
    function scene01out() 
    {
        var tl = new TimelineMax({id:"heroScene01out"});
      
        var heroContentLeft01outStart = $heroContent01.position().left;
      
        // output above
        $("#posLeftEnd span").html(heroContentLeft01outStart);

        // The getBoundingClientRect() method returns the size of an element and its position relative to the viewport.
        // This method returns a DOMRect object with eight properties: left, top, right, bottom, x, y, width, height.
        var heroRowLeft = $heroRow.position().left;
        // console.log("heroRowLeft = " + heroRowLeft);

        var heroContentXoffset = heroRowLeft - heroContentLeft01outStart;
        // console.log("heroContentXoffset = " + heroContentXoffset);

        // animate image out to left, then hide
        tl.to($heroImg01, 2.0, {xPercent:-100, left:"-10%", force3D:true, clearProps:"transform, left"})

        // re-position content to left
        .to($heroContent01, 2.0, { x:heroContentXoffset }, "-=1.5");

        return tl;
    }
  
    master.add( scene01in() )
          .add( scene01out(), "+=2" ) ;
  
  $("#restart").click(function(){
  master.restart();
})
});
              
            
!
999px

Console