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

              
                <div class="js-module || module module-timeline-block">
  <div class="container || js-timeline">
    <div class="timeline row || js-timeline-container">
      <div class="timeline__column || col-12 || js-timeline-column">
        <div class="timeline__item">
          <div class="timeline__row || d-flex flex-column-reverse flex-md-row align-items-center">
            <div class="timeline__image -filler || ratio ratio-1x1">
            </div>
          </div>
          <div class="timeline__content">
            <h3>40th in UK Top 100</h3>
            <p>First time, out of 6, in the Virgin Sunday Times Fast Track 100. First time, out of 6, in the Virgin Sunday Times Fast Track 100.</p>
          </div>
        </div>
      </div>

      <div class="timeline__column || col-12 || js-timeline-column">
        <div class="timeline__item -even">
          <div class="timeline__row || d-flex flex-column-reverse  flex-md-row-reverse align-items-center">
            <div class="timeline__image -filler || ratio ratio-1x1"></div>
          </div>
          <div class="timeline__content">
            <h3>Hong Kong Office</h3>
            <p>We can host social events with up to 30 people at our Hong Kong quarters.</p>
          </div>
        </div>
      </div>

      <div class="timeline__column || col-12 || js-timeline-column">
        <div class="timeline__item">
          <div class="timeline__row || d-flex flex-column-reverse flex-md-row align-items-center">
            <div class="timeline__image -filler || ratio ratio-1x1"></div>
          </div>
          <div class="timeline__content">
            <h3>London Office</h3>
            <p>We can host social events with up to 30 people at our Hong Kong quarters.</p>
          </div>
        </div>
      </div>

      <div class="timeline__column || col-12 || js-timeline-column">
        <div class="timeline__item -even">
          <div class="timeline__row || d-flex flex-column-reverse  flex-md-row-reverse align-items-center">
            <div class="timeline__image -filler || ratio ratio-1x1">
            </div>
          </div>
          <div class="timeline__content">
            <h3>Singapore Office</h3>
            <p>We can host social events with up to 30 people at our Hong Kong quarters. We can host social events with up to 30 people at our Hong Kong quarters.</p>
          </div>
        </div>
      </div>

      <div class="timeline__column || col-12 || js-timeline-column">
        <div class="timeline__item">
          <div class="timeline__row || d-flex flex-column-reverse flex-md-row align-items-center">
            <div class="timeline__image -filler || ratio ratio-1x1">
            </div>
          </div>
          <div class="timeline__content">
            <h3>Random Test</h3>
            <p>This is a random test to see if this will do anything.</p>
          </div>
        </div>
      </div>

      <div class="timeline__column || col-12 || js-timeline-column">
        <div class="timeline__item -even">
          <div class="timeline__row || d-flex flex-column-reverse  flex-md-row-reverse align-items-center">
            <div class="timeline__image -filler || ratio ratio-1x1"></div>
          </div>
          <div class="timeline__content">
            <h3>Hong Kong Office</h3>
            <p>We can host social events with up to 30 people at our Hong Kong quarters.</p>
          </div>
        </div>
      </div>
    </div>
    <div class="timeline__range">
      <div class="draggable__range-range">
        <div class="draggable__range-container || js-timeline-range-container">
          <div class="draggable__range-knob || js-timeline-knob">
            <div class="draggable__range-knob__handle || js-timeline-knob-handle"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                body {
  height: 100vh;
  margin: 0;
}

.container {
  position: relative;
  overflow: hidden;
  max-height: 100vh;
}

.timeline__column {
  &:first-of-type {
    padding-top: 161px;
  }

  &:nth-child(even) {
    margin-top: -130px;
  }

  &:last-of-type {
    .timeline__item {
      padding-bottom: 40px;
    }
  }
}

.timeline__item {
  max-width: 493px;
  width: 100%;

  &.-even {
    margin-left: auto;
  }
}

.timeline__image {
  max-width: 323px;
  max-height: 323px;
  margin-right: 32px;

  .timeline__item.-even & {
    margin-left: 32px;
    margin-right: 0;
  }

  &.-filler {
    background-color: grey;
  }
}

.timeline__content {
  margin-top: 33px;
  max-width: 323px;

  .timeline__item.-even & {
    margin-left: auto;
  }
}

.timeline__date {
  width: 80px;
  height: 80px;
  min-width: 80px;
  min-height: 80px;
  background-color: grey;
  border-radius: 100%;
  color: #fff;
  font-size: 16px;
}

.timeline__range {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: calc(100% - 60px);
  // height: 600px;
}

.draggable__range-range {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 100%;
}

.draggable__range-container {
  background-color: black;
  width: 2px;
  height: 100%;
  position: relative;
}

.draggable__range-knob {
  position: absolute;
  top: 0;
  left: 50%;
}

.draggable__range-knob__handle {
  background-color: pink;
  width: 37px;
  height: 37px;
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 7px solid #fff;
  display: flex;
  justify-content: center;
  align-items: center;

  img {
    max-height: 15px;
    width: auto;
  }
}

              
            
!

JS

              
                gsap.registerPlugin(Draggable);

const timelineSlider = () => {
  const timelineContainer = document.querySelector(".js-timeline-container");
  let timelineContainerHeight = timelineContainer.getBoundingClientRect()
    .height;
  const rangeContainer = document.querySelector(".js-timeline-range-container");
  const knob = document.querySelector(".js-timeline-knob");
  const knobHandle = document.querySelector(".js-timeline-knob-handle");
  const knobHandleWidth = knobHandle.getBoundingClientRect().width;

  let timelineY;
  let draggableY;
  let mapperY;
  let rangeRectY = rangeContainer.offsetHeight;

  timelineY = gsap.timeline({ paused: true });

  draggableY = Draggable.create(knob, {
    type: "y",
    bounds: rangeContainer,
    lockAxis: true,
    edgeResistance: 1,
    overshootTolerance: 0,
    onDrag: updateRange
  });

  function updateMapper() {
    rangeRectY = rangeContainer.offsetHeight;
    mapperY = gsap.utils.mapRange(0, rangeRectY, 0, 1);
    timelineContainerHeight = timelineContainer.getBoundingClientRect().height;
    timelineY.to(timelineContainer, {
      y: -(timelineContainerHeight - rangeRectY - knobHandleWidth),
      duration: 1
    });
  }
  updateMapper();

  window.addEventListener("resize", updateMapper);

  function updateRange() {
    timelineY.progress(mapperY(this.y));
  }

  knobHandle.addEventListener("pointerdown", () => {
    gsap.to(knobHandle, { scale: 1.5 });
  });

  knobHandle.addEventListener("pointerup", () => {
    gsap.to(knobHandle, { scale: 1 });
  });

  rangeContainer.addEventListener("mouseleave", () => {
    gsap.to(knobHandle, { scale: 1 });
  });
};
timelineSlider();

              
            
!
999px

Console