Pen Settings



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


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


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.


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.


                <div class="asset-calculator || container || js-asset-calculator">
    <div class="row">
        <div class="asset-calculator__column ||col-12 col-md-5 d-flex flex-column align-items-center">
            <label class="d-none" for="year-select">Year and multiplier</label>
            <select class="asset-calculator__year-figures || js-asset-calculator-multiplier" name="year" id="year-select">
                <option value="1.1203">1 Year</option>
                <option value="1.2406">2 Year</option>
                <option value="1.3609">3 Year</option>
                <option value="1.4812">4 Year</option>
                <option value="1.6015">5 Year</option>
                <option value="1.7218">6 Year</option>
                <option value="1.8421">7 Year</option>
                <option value="1.9624">8 Year</option>
                <option value="2.0827">9 Year</option>
                <option value="2.2030">10 Year</option>
            <h4 class="asset-calculator__light-text">If you invested</h4>
            <label class="d-none" for="value">Value</label>
            <input class="asset-calculator__value-input || js-asset-calculator-value-input" type="number" id="value" min="10000" max="250000">
        <div class="asset-calculator__column || col-12 col-md-2 d-flex justify-content-center">
            <div class="asset-calculator__range-range">
                <div class="asset-calculator__range-container || js-asset-calculator-range-container" data-min="10000" data-max="250000">
                    <div class="asset-calculator__range-knob || js-asset-calculator-knob">
                        <div class="asset-calculator__range-knob__handle || js-asset-calculator-knob-handle"></div>
        <div class="asset-calculator__column || col-12 col-md-5 d-flex flex-column align-items-center">
            <h4 class="asset-calculator__light-text">you would have</h4>
                <span class="total || js-asset-calculator-total"></span>
                <span class="asset-calculator__light-text">today</span>



                * {
  position: relative;
  box-sizing: border-box;

.asset-calculator {
  .row {
    &:last-of-type {
      margin-top: 49px;
      text-align: center;

      p {
        font-size: 1em;

.asset-calculator__light-text {
  opacity: 0.6;

.asset-calculator__range-range {
  position: relative;
  display: flex;
  justify-content: center;
  width: 40px;
  height: 422px;

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

.asset-calculator__range-knob {
  position: absolute;
  top: 0;
  left: 50%;

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

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

.asset-calculator__value-input {
  -webkit-appearance: textfield;
  border: none;
  background-color: transparent;
  border-bottom: 3px dashed orange;


                const calculator = document.querySelector('.js-asset-calculator')
const total = calculator.querySelector('.js-asset-calculator-total')
const multiplier = calculator.querySelector('.js-asset-calculator-multiplier')
const input = calculator.querySelector('.js-asset-calculator-value-input')
const rangeContainer = calculator.querySelector('.js-asset-calculator-range-container')
const rangeContainerHeight = rangeContainer.getBoundingClientRect().height
const knob = calculator.querySelector('.js-asset-calculator-knob')
const knobHandle = calculator.querySelector('.js-asset-calculator-knob-handle')
let containerY = rangeContainer.getBoundingClientRect().top
let minValue = rangeContainer.getAttribute('data-min')
let maxValue = rangeContainer.getAttribute('data-max')
let interpValue = gsap.utils.interpolate(minValue, maxValue)
let clampValue = gsap.utils.clamp(minValue, maxValue)
let normalizeValue = gsap.utils.normalize(minValue, maxValue)
let newMultiplier = multiplier.value
let typingTimer
let doneTypingInterval = 2000

multiplier.addEventListener('change', () => {
  newMultiplier = multiplier.value
  total.innerHTML = Math.round(input.value * newMultiplier)

let draggable = new Draggable(knob, {
  type: 'y',
  bounds: rangeContainer,
  onDrag: onDrag,

function onDrag() {
  let ratio = this.y / this.maxY
  total.innerHTML = Math.round(clampValue(interpValue(ratio)) * newMultiplier)
  input.value = Math.round(clampValue(interpValue(ratio)))

function init(value) {
  let newValue = normalizeValue(150000)
  gsap.set(knob, { y: rangeContainerHeight * newValue })
  total.innerHTML = Math.round(clampValue(interpValue(newValue)) * newMultiplier)
  input.value = Math.round(clampValue(interpValue(newValue)))

knobHandle.addEventListener('pointerdown', () => {, { scale: 1.5 })

knobHandle.addEventListener('pointerup', () => {, { scale: 1 })

rangeContainer.addEventListener('mouseleave', () => {, { scale: 1 })

input.addEventListener('keyup', () => {
  typingTimer = setTimeout(doneTyping, doneTypingInterval)

input.addEventListener('keydown', () => {

function doneTyping() {
  let typedValue = normalizeValue(input.value)
  console.log(typedValue), { y: rangeContainerHeight * typedValue })
  total.innerHTML = Math.round(clampValue(interpValue(typedValue)) * newMultiplier)
  input.value = Math.round(clampValue(interpValue(typedValue)))