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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <html lang='en'>

<head>
  <meta charset='utf-8'>
  <meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.4/plugins/CSSPlugin.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.4/easing/EasePack.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.4/plugins/AttrPlugin.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.4/TweenLite.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.4/TimelineLite.min.js"></script>
</head>

<body>

  <div class="graph-container">
    <svg style="visibility: hidden" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <defs>
        <rect id="path-1" width="66" height="88" x="819" y="400" rx="2"/>
        <rect id="path-3" width="66" height="88" x="695" y="492" rx="2"/>
        <rect id="path-5" width="66" height="88" x="552" y="436" rx="2"/>
        <rect id="path-7" width="66" height="88" x="386" y="486" rx="2"/>
        <rect id="path-9" width="66" height="88" x="197" y="437" rx="2"/>
        <rect id="path-11" width="66" height="88" x="338" y="340" rx="2"/>
        <rect id="path-13" width="66" height="88" x="221" y="239" rx="2"/>
        <rect id="path-15" width="66" height="88" x="745" y="14" rx="2"/>
        <rect id="path-17" width="66" height="88" x="553" y="53" rx="2"/>
        <rect id="path-19" width="66" height="88" x="395" y="8" rx="2"/>
        <rect id="path-21" width="66" height="88" x="356" y="145" rx="2"/>
        <rect id="path-23" width="66" height="88" x="196" y="93" rx="2"/>
        <filter id="filter-4" width="181.8%" height="161.4%" x="-40.9%" y="-23.9%" filterUnits="objectBoundingBox">
            <feMorphology in="SourceAlpha" radius="4" result="shadowSpreadOuter1"/>
            <feOffset dy="6" in="shadowSpreadOuter1" result="shadowOffsetOuter1"/>
            <feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation="12"/>
            <feComposite in="shadowBlurOuter1" in2="SourceAlpha" operator="out" result="shadowBlurOuter1"/>
            <feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0.22 0 0 0 0 0.22 0 0 0 0 0.22 0 0 0 0.1 0"/>
        </filter>
    </defs>
    <g fill="none" fill-rule="evenodd">
        <g class="safe">
            <path fill="#636D70" d="M28.235 406.294v-4.235h33.883v4.235c0 .78-7.585 1.412-16.942 1.412-9.356 0-16.94-.632-16.94-1.412zm149.647 0v-4.235h33.883v4.235c0 .78-7.585 1.412-16.941 1.412-9.357 0-16.942-.632-16.942-1.412z"/>
            <rect width="240" height="254.118" y="147.941" fill="#BBC4C7" rx="1.412"/>
            <rect width="210.353" height="220.235" x="18.353" y="164.882" fill="#313638" rx="2.824"/>
            <path fill="#484F51" d="M156 216.412h61.412v4.235H156z"/>
            <path fill="#484F51" d="M156 272.882h61.412v4.235H156z"/>
            <path fill="#484F51" d="M156 329.353h61.412v4.235H156z"/>
        </g>
        <g class="partner-logo ADS">
            
            <rect width="65" height="87" x="745.5" y="14.5" stroke="#EBEFF0" rx="2"/>
        </g>
        <g class="partner-logo DTE">
            
            <rect width="65" height="87" x="553.5" y="53.5" stroke="#EBEFF0" rx="2"/>
        </g>
        <g class="partner-logo TWTR">
            
            <rect width="65" height="87" x="395.5" y="8.5" stroke="#EBEFF0" rx="2"/>
        </g>
        <g class="partner-logo GOOG">
           
            <rect width="65" height="87" x="356.5" y="145.5" stroke="#EBEFF0" rx="2"/>
        </g>
        <g class="partner-logo EOAN">
           
            <rect width="65" height="87" x="196.5" y="93.5" stroke="#EBEFF0" rx="2"/>
        </g>
        <g class="partner-logo SIE">
            
            <rect width="65" height="87" x="221.5" y="239.5" stroke="#EBEFF0" rx="2"/>
        </g>
        <g class="partner-logo DPW">
           
            <rect width="65" height="87" x="338.5" y="340.5" stroke="#EBEFF0" rx="2"/>
        </g>
        <g class="partner-logo FB">
           
            <rect width="65" height="87" x="197.5" y="437.5" stroke="#EBEFF0" rx="2"/>
        </g>
        <g class="partner-logo AAPL">
           
            <rect width="65" height="87" x="386.5" y="486.5" stroke="#EBEFF0" rx="2"/>
        </g>
        <g class="partner-logo DBK">
            
            <rect width="65" height="87" x="552.5" y="436.5" stroke="#EBEFF0" rx="2"/>
        </g>
        <g class="partner-logo VOW3">
            
            <rect width="65" height="87" x="695.5" y="492.5" stroke="#EBEFF0" rx="2"/>
        </g>
        <g class="safe-lid">
            <path class="lid-side" fill="#CED8DC" d="M 228 164.5 l 0 0  c 0 0 0 1.5 0 3  V 382   c 0 3.5 0 5.5 0 4 L 228 386 z"/>
            <path class="lid-body" fill="#EBEFF0" d="M 13 164.5  l 214 0 c 1 0 2 1.5 2 3  v 213 c 0 3.5 -1.5 5.5 -5 5 L 15  386 c 0 0 -3.5 1 -5 -4 V 169 c 0 -1 0.5 -3 1.5 -3.5 z"/>
            <ellipse class="locker" cx="229" cy="204" fill="#636D70" rx="0" ry="6"/>
            <ellipse class="locker" cx="229" cy="251" fill="#636D70" rx="0" ry="6"/>
            <ellipse class="locker" cx="229" cy="299" fill="#636D70" rx="0" ry="6"/>
            <ellipse class="locker" cx="229" cy="346" fill="#636D70" rx="0" ry="6"/>
            <ellipse class="handler-bottom" cx="120" cy="275" fill="#CED8DC" rx="28" ry="28"/>
            <ellipse class="handler-middle-round" fill="#EBEFF0" cx="120" cy="275" rx="22" ry="22"/>
            <path class="handler-middle-corner-top" fill="#EBEFF0" d="M 120,255 l -3.9,6.7 l 0,-5.0 z"/>
            <path class="handler-middle-corner-bottom" fill="#EBEFF0" d="M 120,295 l -4.2,-7.0 l 0,5.0 z"/>
            <ellipse class="handler-top" cx="120" cy="275" fill="#BBC4C7" rx="18" ry="18"/>
        </g>
    </g>
</svg>

  </div>

</body>

</html>
              
            
!

CSS

              
                .graph-container {
  .partner-logo {
    fill: #f00;
  }
}

              
            
!

JS

              
                var HowItWorksCollateralizationAnimation = /** @class */ (function() {
  function HowItWorksCollateralizationAnimation(container) {
    this.container = container;
    this.internalIsPlaying = false;
    this.breakpoints = {
      deskBig: "deskBig",
      deskSmall: "deskSmall",
      tablet: "tablet",
      mobileBig: "mobileBig",
      mobileFluid: "mobileFluid"
    };
    window.addEventListener("resize", this.onResize);
    this.currentBreakpoint = this.getCurrentBreakpoint();
    this.initAnimation();
  }
  HowItWorksCollateralizationAnimation.prototype.play = function() {
    if (this.internalIsPlaying) {
      return;
    }
    this.internalIsPlaying = true;
    this.animationOpenSafe();
  };
  HowItWorksCollateralizationAnimation.prototype.pause = function() {
    // nothing to do
  };
  HowItWorksCollateralizationAnimation.prototype.stop = function() {
    this.internalIsPlaying = false;
    this.initAnimation();
  };
  Object.defineProperty(
    HowItWorksCollateralizationAnimation.prototype,
    "isPlaying",
    {
      get: function() {
        return this.internalIsPlaying;
      },
      enumerable: true,
      configurable: true
    }
  );
  HowItWorksCollateralizationAnimation.prototype.showWithoutAnimation = function() {
    this.animationOpenSafe(false);
  };
  HowItWorksCollateralizationAnimation.prototype.dispose = function() {
    window.removeEventListener("resize", this.onResize);
  };
  HowItWorksCollateralizationAnimation.prototype.initAnimation = function() {
    this.setLayouts(this.currentBreakpoint);
    this.initElements();
    this.initLogos();
  };
  HowItWorksCollateralizationAnimation.prototype.onResize = function() {
    var newBreakpoint = this.getCurrentBreakpoint();
    if (
      this.currentBreakpoint !== newBreakpoint ||
      newBreakpoint === this.breakpoints.mobileFluid
    ) {
      this.currentBreakpoint = newBreakpoint;
      this.setLayouts(this.currentBreakpoint);
    }
  };
  HowItWorksCollateralizationAnimation.prototype.initElements = function() {
    this.elementLidBody = this.container.querySelector(".lid-body");
    this.elementLidSide = this.container.querySelector(".lid-side");
    this.elementLockers = this.container.querySelectorAll(".locker");
    this.elementLogos = this.container.querySelectorAll(".partner-logo");
    this.elementHandlerBottom = this.container.querySelector(".handler-bottom");
    this.elementHandlerMiddleRound = this.container.querySelector(
      ".handler-middle-round"
    );
    this.elementHandlerMiddleTop = this.container.querySelector(
      ".handler-middle-corner-top"
    );
    this.elementHandlerMiddleBottom = this.container.querySelector(
      ".handler-middle-corner-bottom"
    );
    this.elementHandlerHandlerTop = this.container.querySelector(
      ".handler-top"
    );
  };
  HowItWorksCollateralizationAnimation.prototype.initLogos = function() {
    Array.apply(this, this.elementLogos).forEach(function(element) {
      return (element.style.opacity = "0");
    });
  };
  /* -------------------------------------------------------------------------
         Elements appearance:
         - safe opens
         - logos appear all together (move + fade in)
         ------------------------------------------------------------------------- */
  HowItWorksCollateralizationAnimation.prototype.animationOpenSafe = function(
    animationEnabled
  ) {
    var _this = this;
    if (animationEnabled === void 0) {
      animationEnabled = true;
    }
    // Safe opening - return initial attributes to all graphic elements at once
    if (animationEnabled && !this.internalIsPlaying) {
      return;
    }
    
    var openingTime = animationEnabled ? 0.7 : 0; // change it to adjust opening speed
    var openLidBody =
      "M 13 165 l 113 -46 c 0.9 -0.4 1.6 1.2 1.6 3.4 v 305 c 0 2.2 -0.7 3.8 -1.6 3.4 L 13 384" +
      " c -0.9 -0.4 -1.6 -1.9 -1.6 -3.6 V 169 c 0 -1.6 0.7 -3.1 1.6 -3.5 z";
    TweenLite.to(this.elementLidBody, openingTime, {
      attr: { d: openLidBody },
      ease: Power1.easeOut
    });
    var openLidSide =
      "M 126 119 l 27 8 c 0.6 0.2 1 0.7 1 1.4 V 422 c 0 0.6 -0.4 1.2 -1 1.4 L 126 431 z";
    TweenLite.to(this.elementLidSide, openingTime, {
      attr: { d: openLidSide },
      ease: Power1.easeOut
    });
    var openLockerY = [188, 246, 304, 362];
    openLockerY.forEach(function(openLocker, index) {
      TweenLite.to(_this.elementLockers[index], openingTime, {
        attr: { cx: 142, cy: openLocker, rx: 4 },
        ease: Power1.easeOut
      });
    });
    TweenLite.to(this.elementHandlerBottom, openingTime, {
      attr: { cx: 64, rx: 16 },
      ease: Power1.easeOut
    });
    TweenLite.to(this.elementHandlerMiddleRound, openingTime, {
      attr: { cx: 63, rx: 11.5 },
      ease: Power1.easeOut
    });
    var openCornerTop = "M 58,255 l -3.9,6.7 l 0,-5.0 z";
    TweenLite.to(this.elementHandlerMiddleTop, openingTime, {
      attr: { d: openCornerTop },
      ease: Power1.easeOut
    });
    var openCornerBottom = "M 58,295 l -4.2,-7.0 l 0,5.0 z";
    TweenLite.to(this.elementHandlerMiddleBottom, openingTime, {
      attr: { d: openCornerBottom },
      ease: Power1.easeOut
    });
    TweenLite.to(this.elementHandlerHandlerTop, openingTime, {
      attr: { cx: 54, rx: 9 },
      ease: Power1.easeOut
    });
    // Move logos (directions if from safe center to initial position)
    var logosDistances = [
      { x: 72, y: 23 },
      { x: 54, y: 20 },
      { x: 38, y: 23 },
      { x: 17, y: 15 },
      { x: 34, y: 20 },
      { x: 20, y: 0 },
      { x: 31, y: -20 },
      { x: 18, y: -20 },
      { x: 37, y: -24 },
      { x: 53, y: -19 },
      { x: 67, y: -25 }
    ];
    var gain = 5; // change it to make distance shorter
    logosDistances.map(function(delta) {
      delta.x = delta.x * gain;
      delta.y = delta.y * gain;
    });
    var appearStart = openingTime * 0.65; // change it to change start of logos appearance
    var appearTime = animationEnabled ? 0.7 : 0; // change it to adjust moving speed
    // Dennis: here is the laggy animation!
    setTimeout(function() {
      logosDistances.forEach(function(logosDistance, index) {
        TweenLite.fromTo(
          _this.elementLogos[index],
          appearTime,
          {
            x: "-=" + logosDistance.x,
            y: "+=" + logosDistance.y,
            opacity: 0
          },
          {
            x: 0,
            y: 0,
            opacity: 1,
            delay: appearStart,
            ease: Power2.easeOut
          }
        );
      });
    }, 3000);
  };
  /* -------------------------------------------------------------------------
         Set svg size and cut it off for each screen width,
         Hide some logos at small screens
         Scale safe and logos for small screens
         ------------------------------------------------------------------------- */
  HowItWorksCollateralizationAnimation.prototype.setLayouts = function(
    currentBreakpoint
  ) {
    var mainSvg = this.container.getElementsByTagName("svg")[0];
    var safe = this.container.getElementsByClassName("safe")[0];
    var lid = this.container.getElementsByClassName("safe-lid")[0];
    var logos = this.container.getElementsByClassName("partner-logo");
    var logoVOW3 = this.container.getElementsByClassName("VOW3")[0];
    var logoADS = this.container.getElementsByClassName("ADS")[0];
    var logoDTE = this.container.getElementsByClassName("DTE")[0];
    var logoGOOG = this.container.getElementsByClassName("GOOG")[0];
    var logoDPW = this.container.getElementsByClassName("DPW")[0];
    var logoDBK = this.container.getElementsByClassName("DBK")[0];
    var logoAAPL = this.container.getElementsByClassName("AAPL")[0];
    if (currentBreakpoint === this.breakpoints.deskBig) {
      TweenLite.set(logos, {
        visibility: "visible"
      });
      TweenLite.set(mainSvg, {
        width: 885,
        scale: 1,
        transformOrigin: "top left",
        attr: { viewBox: "0 0 885 600" }
      });
      TweenLite.set([safe, logos, lid], {
        scale: 1,
        transformOrigin: "top left"
      });
    } else if (currentBreakpoint === this.breakpoints.deskSmall) {
      TweenLite.set(logos, {
        visibility: "visible"
      });
      TweenLite.set([logoVOW3, logoADS], {
        visibility: "hidden"
      });
      TweenLite.set(mainSvg, {
        width: 885,
        scale: 1,
        transformOrigin: "top left",
        attr: { viewBox: "0 0 885 600" }
      });
      TweenLite.set([safe, logos, lid], {
        scale: 1,
        transformOrigin: "top left"
      });
    } else if (currentBreakpoint === this.breakpoints.tablet) {
      TweenLite.set(logos, {
        visibility: "visible"
      });
      TweenLite.set([logoVOW3, logoADS, logoDTE, logoGOOG, logoDPW, logoDBK], {
        visibility: "hidden"
      });
      TweenLite.set(mainSvg, {
        width: 690,
        scale: 1,
        transformOrigin: "top left",
        attr: { viewBox: "0 0 690 600" }
      });
      TweenLite.set([safe, logos, lid], {
        scale: 1,
        transformOrigin: "top left"
      });
    } else if (currentBreakpoint === this.breakpoints.mobileBig) {
      TweenLite.set(logos, {
        visibility: "visible"
      });
      TweenLite.set([logoVOW3, logoADS, logoDTE, logoDBK, logoAAPL], {
        visibility: "hidden"
      });
      TweenLite.set(mainSvg, {
        width: 323,
        scale: 1,
        transformOrigin: "top left",
        attr: { viewBox: "0 0 533 600" }
      });
      TweenLite.set([safe, logos, lid], {
        scale: 1.15,
        transformOrigin: "top left"
      });
    } else if (currentBreakpoint === this.breakpoints.mobileFluid) {
      TweenLite.set(logos, {
        visibility: "visible"
      });
      TweenLite.set([logoVOW3, logoADS, logoDTE, logoDBK, logoAAPL], {
        visibility: "hidden"
      });
      TweenLite.set(mainSvg, {
        width: 323,
        scale: window.innerWidth / 375,
        transformOrigin: "top left",
        attr: { viewBox: "0 0 533 600" }
      });
      TweenLite.set([safe, logos, lid], {
        scale: 1.15,
        transformOrigin: "top left"
      });
    }
    TweenLite.set(mainSvg, { visibility: "visible" });
  };
  /* -------------------------------------------------------------------------
         Return current layout name.
         375px is the size of svg fixed width at mobile screen.
         Below 375px we need to scale svg to keep it within screen width
         ------------------------------------------------------------------------- */
  HowItWorksCollateralizationAnimation.prototype.getCurrentBreakpoint = function() {
    var windowWidth = window.innerWidth;
    if (windowWidth >= 1200) {
      return this.breakpoints.deskBig;
    } else if (windowWidth >= 992) {
      return this.breakpoints.deskSmall;
    } else if (windowWidth >= 768) {
      return this.breakpoints.tablet;
    } else if (windowWidth >= 375) {
      return this.breakpoints.mobileBig;
    } else {
      return this.breakpoints.mobileFluid;
    }
  };
  return HowItWorksCollateralizationAnimation;
})();

const animation = new HowItWorksCollateralizationAnimation(
  document.querySelector(".graph-container")
);

animation.play();

              
            
!
999px

Console