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

              
                <div id="app">
  <div class="hud">
    <scrubber :value="230" :min="0" :max="500" steps="1" label="Attack" measure="ms" readout="value"></scrubber>  
  <scrubber :value="1800" :min="0" :max="5000" :steps="50" label="Release" measure="ms" readout="value"></scrubber> 
    <div class="divider"></div>
     <scrubber :value="8" :min="1" :max="30" :steps="steps" label="Ratio" measure="Ratio" readout="value" rappend=":1"></scrubber> 
    <scrubber value="0" :min="0" :max="30" steps=".1" label="Makeup" measure="db" readout="value"></scrubber> 
    </div>
</div>
              
            
!

CSS

              
                $darkGray: #34414C;
$lightGray: #7A8B98;
$blackish: #13161a;
$guageFill: #F06C21;
$primaryText:  #F1F3F5;
$secondaryText: #7A8B98;
$hudColor: #252B33;
* {
  -webkit-backface-visibility: hidden;
}

.slob * {
  user-select: none;
}
.divider {
  width: 2px;
  background-color: $lightGray;
  height: 80%;
  opacity: .3;
  margin: 0 0 0 3px;
}
html, body {
  height: 100%;
}
body {
  font-family: "Helvetica Neue", "Arial", sans-serif;
  background: $darkGray;
  color: #E2CFEA;
  -webkit-font-smoothing: antialiased;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
	align-items: center;
}

#app {
  height: 500px;
  width: 828px;
  background: url('https://dl.airtable.com/.attachmentThumbnails/1bc77a0f657111cbca8befd517d92e8a/a34a7d5e') center center no-repeat;
  background-size: contain;
  position: relative;
}
.hud {
	display: flex;
	align-items: center;
  height: 90px;
  position: absolute;
  top: 375px;
  left: 138px;
  background: $hudColor;
  border-radius: 10px;
  border: 2px solid $hudColor;
  box-shadow: 0 2px 50px rgba(0,0,0,.4);
  transition: ease-out .3s;
}
.hud:hover {
  box-shadow: 0 2px 50px rgba(0,0,0,.5);
}
// a slider & knob have a baby... 
.slob {
  transition: ease .15s;
  transform: scale(.6);
  position: relative;
  width: 90px;
  height: 120px;
}
.slob.is-interacting {
  cursor: ns-resize;
  // transform: scale(1);
}
.slob-label {
  position: absolute;
  font-family: sans-serif;
  color: $primaryText;
  font-size: 18px;
  text-align: center;
  bottom: 2px;
  width: 90px;
  user-select: none;
  transition: ease .4s;
}
.slob.is-interacting .slob-label{
  color: $secondaryText;
}
.slob-label-ancillary {
  position: absolute;
  top: 100px;
  width: 100%;
  text-align: center;
  opacity: 0;
  transition: ease .3s;
  user-select: none;
}
.slob.is-interacting .slob-label-ancillary {
  top: -20px;
  // opacity: .8;
  #color: $primaryText;
}
.slob .slob-read-out{
  position: absolute;
  text-align: center;
  top: 47px;
  width: 100%;
  margin-top: -16px;
  font-size: 23px;
  font-family: sans-serif;
  z-index: 1;
  color: #fff;
  opacity: 1;
  user-select: none;
  cursor: ns-resize;
  transition: ease-in .15s;
}
.slob:hover .slob-read-out,
.slob.is-interacting .slob-read-out {
  top: 47px;
  //opacity: .8;
}


.slob:hover .arrow, .slob.is-interacting .arrow {
  border: solid white;
  border-width: 0 3px 3px 0;
  display: inline-block;
  padding: 3px;
  position: absolute;
  opacity: .2;
  transition-property: all;
  transition-duration: .25s;
  transition-timing-function: ease;
}
.slob .arrow.up {
  top: 30px;
}
.slob .down {
  bottom: 30px;
}
.slob.is-interacting .arrow {
  opacity: .5;
}

.slob:hover .arrow.up, .slob.is-interacting .arrow.up {
  top: 25px;
  left: 50%;
  margin-left: -4px;
  transform: rotate(-135deg);
  -webkit-transform: rotate(-135deg);
}

.slob:hover .arrow.down, .slob.is-interacting .arrow.down {
  bottom: 25px;
  left: 50%;
    margin-left: -4px;
  transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
}

.outside-container {
  background: $hudColor;
  width: 86px;
  height: 86px;
  position: absolute;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  transition: ease-in .15s;
  box-shadow: 0 0 0 rgba(0,0,0,.8);
}

.slob.is-interacting .outside-container {
  box-shadow: 0 0 40px rgba(0,0,0,.2);
}
.outside {
  cursor: ns-resize;
  position: absolute;
	width: 90px;
	height: 90px;
  background: rgba(19, 22, 26,.6);
  clip-path: circle(46% at 50% 50%);
}

.inside-fill {
  position: absolute;
  top:0px;
  left: 0px;
  right: 10px;
  width: 100px;
  height: 100px;
  background: $guageFill;
  opacity: .2;
  z-index: 1;
}
.inside {
  position: absolute;
  top: 0px;
  left: 0px;
  right: 10px;
  width: 100px;
  height: 100px;
  background: $guageFill;
/*   clip-path: circle(50% at 50% 50%); */
}

.inside-ring {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  background: $blackish;
  clip-path: circle(46% at 50% 50%);
}

.vue-scrubber {
   z-index: 2;
  font-size: 15px;
  text-align: center;
  border: 0;

  cursor: ns-resize;
  background: rgba(0, 0, 0, 0.08);
  color: white;
  -webkit-user-select: none;
  user-select: none;
  
font-feature-settings:"lnum" 1;
}
.vue-scrubber-circle {
  width: 100px;
  height: 100px;
  border-radius: 100px;
}

.vue-scrubber:hover, .vue-scrubber:focus {
  outline: 0;
  box-shadow: none;
}


/** Demo CSS */

              
            
!

JS

              
                // Scrubber component
// Lets the user change an input field value by dragging the mouse left/right.
// Manual text input is still possible.

Vue.component('scrubber', {
    data: function() {
    return {
      isMouseDown: false,
      initialMouse: null,
      value: 0
    }
  },
  computed: {
    // returns the number of decimals based on the step value
    // e.g. "0.25" returns "2"
    decimals: function() {
      return this.steps.toString().substr((this.steps).toString().indexOf(".")).length - 1;
    },
    
    // every time the value changes, we need to make sure it stays inside the min/max
    constrainedValue: function() {
      return this.constrain(this.value, this.min, this.max, this.decimals);
    },
    constrainedValueAsPercentage: function() {
      var val = this.constrain(this.value, this.min, this.max, this.decimals);
      var percInt = parseFloat((val / this.max) * 100);
      //var percentAsInt = this.round(percInt, this.decimals);
      var decimals = this.decimals > 0 && percInt != 100 ? 1 : 0;
      var scrubbedPercVal = Number(percInt).toFixed(decimals);
      // return percInt;
      return scrubbedPercVal;
    },
  },
  
  // props that the scrubber can receive
  // value: initial value
  // min: minimum value
  // max: maximum value
  // steps: increments for each pixel the mouse is moved
  props: ["value", "min", "max", "steps", "label", "measure", "readout", "rappend"],
  
  // the template
  template: `<div v-bind:class="{slob: true, 'is-interacting': isMouseDown}" v-on:mousedown='handleMouseDown' v-on:keypress='handleInput' v-on:keydown.up='handleKeyCodeUp' v-on:keydown.down='handleKeyCodeDown' >
<div class="slob-label-ancillary">{{label}}</div>
<div class="outside-container">      </div>
    <div class="outside">
      <div class="inside" v-bind:style="{top: ((constrainedValueAsPercentage-100)*-1)+ 'px'}">
      </div>
      
      <div class="inside-ring" >
      </div>
      <div class="inside-fill"  v-bind:style="{top: ((constrainedValueAsPercentage-100)*-1) + 'px', opacity: (constrainedValueAsPercentage)*.004}"></div>
      <span class="slob-read-out">{{( readout == 'percent' ? constrainedValueAsPercentage : constrainedValue)}}{{( rappend.length > 0 ? ':1' : '')}}</span><span></span>
        <div class="arrow up"> </div>
    <div class="arrow down"> </div>

<input class='vue-scrubber vue-scrubber-circle' v-model='constrainedValue' v-on:change='handleChange' />
</div><div class="slob-label">{{(isMouseDown ? measure : label ) }}</div></div>`,

  methods: {
    
    // constrains a number to not exceed the min/max
    // decimals: rounding precision
    constrain: function(value, min, max, decimals) {
      decimals = typeof decimals !== 'undefined' ? decimals : 0;

      if (min != undefined && max != undefined) {
        return this.round(Math.min(Math.max(parseFloat(value), min), max), decimals);
      } else {
        return value;
      }
    },
    
    // method to round a number to given decimals
    round: function(value, decimals) {
       return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);
    },
    handleInput: function (event) {
      // only allow numeric keys
      if (event.keyCode < 48 || event.keyCode > 57) {
        event.preventDefault();
      }
    },
    
    handleChange: function (event) {

      this.value = isNaN(parseFloat(event.target.value)) ? 0 : parseFloat(event.target.value);
    },
    
    handleKeyCodeUp: function (event) {
      event.preventDefault();
        this.value += parseFloat(this.steps);
    },
    
    handleKeyCodeDown: function (event) {
      event.preventDefault();
        this.value -= parseFloat(this.steps);
    },
    
    // mouse handler
    handleMouseDown: function(event) {
console.log('mouse down');
      // enable scrubbing
      this.mouseDown = true;
      this.isMouseDown = true;

      // remember the initial mouse position when the scubbing started
      this.initialMouse = {
        x: event.clientX,
        y: event.clientY
      }

      // remember the initial value
      this.initialValue = this.value;

      // register global event handlers because now we are not bound to the component anymore
      document.addEventListener("mousemove", this.handleMouseMove)

      // global mouse up listener
      document.addEventListener("mouseup", this.handleMouseUp)
      
    },
    handleMouseUp: function($event) {

      // disable scrubbing
      this.mouseDown = false;
      this.isMouseDown = false;
      
      document.removeEventListener("mousemove", this.handleMouseMove)
      document.removeEventListener("mouseup", this.handleMouseUp)

    },
    
    // the actual translation of mouse movement to value change…
    handleMouseMove: function(event) {

      // scrub if the mouse is being pressed
      if (this.mouseDown) {
        var newValue = this.initialValue + ((this.initialMouse.y - event.clientY) * this.steps)

        // constrain the value to the min/max
        this.value = this.constrain(newValue, this.min, this.max, this.decimals);

      }
    }
  }
})

// demo app with global data properties that get passed down the a few scrubbers
var app = new Vue({
  el: "#app",
  data: {
    min: 0,
    max: 300,
    steps: 1,
    value: 100,
    testVal: 232.23323
    // demo: "<scrubber :min='10' :max='100' :steps='1' :value='50'></scrubber>"
  }
})
              
            
!
999px

Console