Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <svg class="c-logo" height="48" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48">
    <path class="c-logo__inner" d="M14.9 6.1h19v25.4h-19z"/>
    <path class="c-logo__outer" height="48" d="M5.8 0v36.3h10.7V48l25.6-11.7V0H5.8zm10.5 29.4V6.9h5.8v8.3h4.2V6.9h5.8v22.6h"/>
  </svg>

<main>
<section></section>
<section class="js-change-logo"></section>
<section></section>
<section class="js-change-logo"></section>
<section></section>
<section class="js-change-logo"></section>
<section></section>
<section class="js-change-logo"></section>

</main>

              
            
!

CSS

              
                body {
  font-family:sans-serif;
}

main {
  float: right;
}

.c-logo {
  left: 25px;
  overflow: hidden;
  position: fixed;
  top: 25px;
  z-index: 999999;
}

.c-logo__outer {
  fill: #4dabfc;
}

.c-logo__inner {
  fill: #fff;
}



section:nth-of-type(odd) {
   background: pink;
  height: 40vh;
  width: 400px;
}

section:nth-of-type(even) {
   background: #4dabfc;
  height: 40vh;
  width: 400px;
}



              
            
!

JS

              
                const mobile = {
  controller: new ScrollMagic.Controller(),

  changeLogo: {
    init: () => {
      console.log("init tweens an scrollmagic");
      const tweens = {
        enterOuter: () => {
          TweenMax.fromTo(
            ".c-logo__outer",
            1,
            { fill: "#4dabfc" },
            { fill: "#fff" }
          );
        },
        enterInner: () => {
          TweenMax.fromTo(
            ".c-logo__inner",
            1,
            { fill: "#fff" },
            { fill: "#4dabfc" }
          );
        },
        leaveOuter: () => {
          TweenMax.fromTo(
            ".c-logo__outer",
            1,
            { fill: "#fff" },
            { fill: "#4dabfc" }
          );
        },
        leaveInner: () => {
          TweenMax.fromTo(
            ".c-logo__inner",
            1,
            { fill: "#4dabfc" },
            { fill: "#fff" }
          );
        }
      };
      const trigger = document.querySelectorAll(".js-change-logo");

      trigger.forEach(id => {
        const scene = new ScrollMagic.Scene({
          triggerElement: id,
          reverse: true,
          triggerHook: 0.065,
          duration: id.clientHeight
        })
          .on("enter", () => {
            tweens.enterOuter();
            tweens.enterInner();
          })
          .on("leave", () => {
            tweens.leaveOuter();
            tweens.leaveInner();
          })
          .addIndicators()
          .addTo(mobile.controller);
      });
    },
    destroyTweens: () => {
      console.log("kill tweens");
      TweenMax.killTweensOf(".c-logo__outer");
      TweenMax.killTweensOf(".c-logo__inner");
      TweenMax.set(".c-logo__outer", { clearProps: "all" });
      TweenMax.set(".c-logo__inner", { clearProps: "all" });
    }
  }
};

$(window).on("resize", function() {
  var win = $(this); //this = window
  if (win.width() <= 450) {
    // reanble controller if disabledbed before - doesnt work 
    mobile.controller.enabled(true);
    mobile.changeLogo.init();
  } else {
    // disable scrollmagic controller
    mobile.controller.enabled(false);
    // destroy tweens
    mobile.changeLogo.destroyTweens();
  }
}).resize();

/* This Pen Loads the Following

  TweenMax: latest version
    -TweenLite
    -TweenMax
    -TimelineLite
    -TimelineMax
    -CSSPlugin
    -BezierPlugin
    -DirectionalRotationPlugin
    -AttrPlugin
    -RoundPropsPlugin
    -EasePack
    
  Please use the minimal amount of code possible to recreate the problem you are experiencing.
  
*/

              
            
!
999px

Console