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

              
                .view__menu
  .menu__inner
    .btn.btn--play-pause
      svg.btn__icon(viewbox="0 0 40 40")
        circle.icon__shape.icon__shape--circle.icon__shape--orange(cx="20", cy="20", r="19", transform="rotate(-90 20 20)")
        circle.icon__shape.icon__shape--circle.icon__shape--white(cx="20", cy="20", r="19", transform="rotate(-90 20 20)")
        polygon.icon__shape.icon__shape--triangle(points="16,14 16,26 27.5,19.8")
        line.icon__shape.icon__shape--line(x1="24", y1="14", x2="24", y2="26")
      .btn__shadow
    .btn.btn--volume.btn--volume-2
      svg.btn__icon(viewbox="0 0 174 40")
        path.icon__shape(d="M2.8,20.4c0-17.4,19-19,19-19v38C21.8,39.4,2.8,37.8,2.8,20.4z")
        line.icon__shape.icon__shape--line-mute.icon__shape--orange(x1="26", y1="7.9", x2="1", y2="32.9")
        line.icon__shape.icon__shape--line-mute.icon__shape--white(x1="26", y1="7.9", x2="1", y2="32.9")
        line.icon__shape.icon__shape--line-controls.icon__shape--translucide(x1="37.8", y1="20", x2="162.8", y2="20")
        line.icon__shape.icon__shape--line-controls.icon__shape--white(x1="37.8", y1="20", x2="162.8", y2="20")
        circle.icon__shape.icon__shape--circle-big.icon__shape--translucide(cx="24.8", cy="20", r="19", transform="rotate(45 25 20)")
        circle.icon__shape.icon__shape--circle-medium.icon__shape--translucide(cx="24.8", cy="20", r="13", transform="rotate(-45 25 20)")
        circle.icon__shape.icon__shape--circle-small.icon__shape--translucide(cx="24.8", cy="20", r="7", transform="rotate(-45 25 20)")
        circle.icon__shape.icon__shape--circle-controls(cx="37.8", cy="20", r="0")
        circle.icon__shape.icon__shape--circle-placeholder(cx="37.8", cy="20", r="1")
      .btn__shadow
    .menu__credits
      | Designed by 
      a.menu__link(href="http://sneups.net", target="_blank") Julie Muckensturm

              
            
!

CSS

              
                @import 'bourbon';

$black: #000000;
$white: #ffffff;
$grey: #333333;
$dark-grey: #333333;
$orange: #ffa700;

body {
  background-color: rgba(0, 0, 0, 0.75);
  color: $white;
  overflow: hidden;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

.view__menu {
  background-color: $black;
  bottom: 0;
  left: 0;
  height: 120px;
  position: absolute;
  width: 100%;
  
  .menu__inner {
    left: 0;
    margin-top: -20px;
    padding: 0 40px;
    position: absolute;
    top: 50%;
    width: 100%;
  }
  
  .menu__credits {
    color: $grey;
    float: right;
    font-size: 14px;
    letter-spacing: 1px;
    line-height: 40px;
  }
  .menu__link {
    color: $white;
    display: inline-block;
    position: relative;
    text-decoration: none;
    text-transform: uppercase;
    
    &:after {
      background-color: $white;
      content: '';
      height: 2px;
      left: 0;
      margin-top: 10px;
      position: absolute;
      top: 50%;
      width: 100%;
      transition: transform 500ms $ease-out-expo;
      transform-origin: left center;
      transform: scaleX(0);
    }
    &:hover:after {
      transform: scaleX(1);
    }
  }
  
  .btn {
    float: left;
    margin-right: 40px;
    position: relative;
  }
  .btn .btn__icon {
    height: 40px;
  }
  .btn .btn__shadow {
    background-color: $white;
    border-radius: 50%;
    left: -15px;
    height: 70px;
    opacity: 0;
    pointer-events: none;
    position: absolute;
    top: -15px;
    width: 70px;
  }
  .btn .btn__icon .icon__shape {
    fill: none;
    stroke: $white;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
    
    &--translucide {
      opacity: 0.2;
    }
    &--orange {
      stroke: $orange;
    }
  }
  
  .btn--play-pause .btn__icon .icon__shape--circle {
    height: 40px;
    stroke-dasharray: 119.38052 119.38052; // r = 19 ; 2.PI.r = 119.38052
    width: 40px;
  }
  .btn--play-pause .btn__icon .icon__shape--line {
    stroke-dasharray: 12 12; // AC = 12 ; AC AC
  }
  .btn--play-pause .btn__icon .icon__shape--triangle {
    stroke-dasharray: 12 38; // AB = BC = 13 ; AC = 12 ; p = AB + BC + AC = 38
  }
  
  .btn--volume .btn__shadow {
    left: -12px;
  }
  .btn--volume .btn__icon .icon__shape--line-mute {
    stroke-dasharray: 35.3553 70.71067; // 
    stroke-dashoffset: 35.3553;
    // animation : offset to 0
  }
  .btn--volume .btn__icon .icon__shape--line-controls {
    stroke-dasharray: 125 250; // l = 125 ; l 2.l
    stroke-dashoffset: 125;
    // animation : offset to 0
  }
  .btn--volume .btn__icon .icon__shape--circle-small {
    opacity: 1;
    stroke-dasharray: 10.99557 87.96459; // r = 7 ; 1/2.PI.r = 10.99557 4.PI.r = 87.96459
    // animation : offset to 10.99557 // r = 7 ; 1/2.PI.r = 10.99557
  }
  .btn--volume .btn__icon .icon__shape--circle-medium {
    opacity: 1;
    stroke-dasharray: 20.42035 163.36281; // r = 13 ; 1/2.PI.r = 20.42035 4.PI.r = 163.36281
    // animation : array to 0 163.36281 // r = 13 ; 4.PI.r = 163.36281
    // animation : offset to -10.21017 // r = 13 ; -1/4.PI.r = -10.21017
  }
  .btn--volume .btn__icon .icon__shape--circle-big {
    stroke-dasharray: 29.84513 238.76104; // r = 19 ; 1/2.PI.r = 29.84513 4.PI.r = 238.76104
    stroke-dashoffset: -89.53539; // r = 19 ; -3/2.PI.r = 89.53539
    // animation : offset to -119.38052 // r = 19 ; -2.PI.r = -119.38052
  }
  .btn--volume .btn__icon .icon__shape--circle-controls {
    cursor: pointer;
    display: block;
    fill: $white;
    opacity: 0.2;
    stroke: none;
    // animation : radius to 8
  }
  .btn--volume .btn__icon .icon__shape--circle-placeholder {
    fill: $white;
    opacity: 0;
    stroke: none;
  }
}

              
            
!

JS

              
                TweenLite.defaultEase = Expo.easeOut;

var utils = {
  map: function (value, min1, max1, min2, max2) {
    var value1 = (value - min1) / (max1 - min1);
    var value2 = (value1 * (max2 - min2)) + min2;

    return value2;
  }
};

var UIButton = (function () {
  'use strict';

  var UIButton = function ($element) {

    this.$element = $element;
    this.$shadow = this.$element.find('.btn__shadow');
    
    this.clickableArea = {x: 0, y: 0, w: this.$element.width(), h: this.$element.height()};
    this.handlers = {};

    this.$element.on('click', function (evt) {
      var offsetX = evt.pageX - this.$element.offset().left;
      var offsetY = evt.pageY - this.$element.offset().top;
      
      if (offsetX >= this.clickableArea.x && offsetX <= this.clickableArea.x + this.clickableArea.w && offsetY >= this.clickableArea.y && offsetY <= this.clickableArea.y + this.clickableArea.h) {
        this.trigger('click', evt);
      }
    }.bind(this));
    
    this.on('click', this.shadow.bind(this));
  };
  
  UIButton.prototype.shadow = function () {
    var timeline = new TimelineMax();
    
    timeline.set(this.$shadow, {opacity: 0.15});
    timeline.to(this.$shadow, 1, {opacity: 0});
  };

  UIButton.prototype.on = function (name, fn) {
    if (typeof name === 'string' && typeof fn === 'function') {
      this.handlers[name] = (this.handlers[name] || []).concat(fn);
    }
  };

  UIButton.prototype.trigger = function (name) {
    var args = Array.prototype.slice.call(arguments);
    
    for (var i=0; i<(this.handlers[name] || []).length; i++) {
      this.handlers[name][i].apply(this, args.slice(1));
    }
  };

  return UIButton;
})();

var PlayPauseUIButton = (function () {
  'use strict';
  
  var PlayPauseUIButton = function ($element) {
    
    UIButton.call(this, $element);
    
    this.timeline = new TimelineMax({paused: true});
    
    this.timeline.staggerTo(this.$element.find('.icon__shape--circle'), 1.75, {strokeDasharray: '119.38052 0', strokeDashoffset: -119.38052}, 0.05, 0);
    this.timeline.to(this.$element.find('.icon__shape--triangle'), 1.75, {strokeDasharray: '38 0', strokeDashoffset: 38}, 0);
    this.timeline.to(this.$element.find('.icon__shape--line'), 0.5, {strokeDashoffset: -12}, 0);
    
    this.timeline.to(this.$element.find('.icon__shape--line'), 0.5, {opacity: 0}, 0.1);
    
    this.on('click', this.toggle);
    
  };
  
  PlayPauseUIButton.prototype = Object.create(UIButton.prototype);
  
  PlayPauseUIButton.prototype.toggle = function () {
    if (this.timeline.yoyo()) {
      this.pause();
    } else {
      this.play();
    }
  };
  
  PlayPauseUIButton.prototype.play = function () {
    this.timeline.yoyo(true).tweenTo(this.timeline.duration());
  };
  
  PlayPauseUIButton.prototype.pause = function () {
    this.timeline.yoyo(false).tweenTo(0, {ease: Expo.easeOut});
  };
  
  return PlayPauseUIButton;
})();

var VolumeUIButton = (function () {
  'use strict';
  
  var VolumeUIButton = function ($element) {
    
    UIButton.call(this, $element);
    
    this.level = 2;
    this.progress = 50;
    this.volume = 50;
    
    this.clickableArea.w = 45;
    
    this.gestureManager = new Hammer.Manager(this.$element.find('.icon__shape--circle-controls')[0], {touchAction: 'none'});
    this.gestureManager.add(new Hammer.Press({time: 10}));
    this.gestureManager.add(new Hammer.Pan({direction: Hammer.DIRECTION_HORIZONTAL, threshold: 0}));
    
    this.timeline = new TimelineMax();
    
    this.on('click', this.toggle);
    
  };
  
  VolumeUIButton.prototype = Object.create(UIButton.prototype);
  
  VolumeUIButton.prototype.shadow = function () {
    if (!this.timeline.yoyo()) {
      UIButton.prototype.shadow.call(this);
    }
  };
  
  VolumeUIButton.prototype.toggle = function (evt) {    
    if (!this.timeline.yoyo()) {
     this.open();
    }
  };
  
  VolumeUIButton.prototype.open = function () {
    var tweens = [];
    
    this.timeline.yoyo(true).clear();
    
    tweens.push(new TweenMax.to(this.$element.find('.icon__shape--circle-small'), 0.75, {strokeDashoffset: 10.99557}));
    tweens.push(new TweenMax.to(this.$element.find('.icon__shape--circle-medium'), 0.75, {opacity: 1, strokeDasharray: '0 163.36281', strokeDashoffset: -10.21017}));
    tweens.push(new TweenMax.to(this.$element.find('.icon__shape--circle-big'), 0.75, {strokeDashoffset: -119.38052}));
    
    this.timeline.add(tweens);
    
    var tweens = [];
    
    tweens.push(new TweenMax.to(this.$element.find('.icon__shape--circle-small'), 0.5, {opacity: 0}));
    tweens.push(new TweenMax.to(this.$element.find('.icon__shape--circle-big'), 0.5, {opacity: 0}));
    
    this.timeline.add(tweens, 0.25);
    
    this.timeline.set(this.$element.find('.icon__shape--circle-medium'), {opacity: 0});
    this.timeline.set(this.$element.find('.icon__shape--circle-placeholder'), {opacity: 1});
    
    var tweens = [];
    
    tweens.push(new TweenMax.to(this.$element.find('.icon__shape--line-controls.icon__shape--translucide'), 0.5, {strokeDashoffset: 0}));
    tweens.push(new TweenMax.to(this.$element.find('.icon__shape--circle-controls'), 0.5, {attr: {r: 8}, ease: Back.easeOut}));
    
    this.timeline.add(tweens, 0.75);
    
    this.timeline.to({progress: 0}, (0.5 * this.volume / 100), {progress: this.volume, onUpdate: function (tween) {
      this.progress = tween.target.progress;
      this.refresh();
    }, onUpdateParams: ['{self}'], onUpdateScope: this}, 0.75);
    
    this.timeline.add(this.drag.bind(this));
  };
  
  VolumeUIButton.prototype.close = function () {
    var tweens = [];
    
    this.timeline.yoyo(false).clear();
    
    this.timeline.to({progress: this.volume}, 0.5 * this.volume / 100, {progress: 0, onUpdate: function (tween) {
      this.progress = tween.target.progress;
      this.refresh();
    }, onUpdateParams: ['{self}'], onUpdateScope: this}, 'progressive');
    
    tweens.push(new TweenMax.to(this.$element.find('.icon__shape--line-controls.icon__shape--translucide'), 0.5, {strokeDashoffset: 125}));
    tweens.push(new TweenMax.to(this.$element.find('.icon__shape--circle-controls'), 0.5, {attr: {r: 0}}));
    
    this.timeline.add(tweens, 'progressive-=0.5');
    
    this.timeline.set(this.$element.find('.icon__shape--circle-medium'), {opacity: 1});
    this.timeline.set(this.$element.find('.icon__shape--circle-placeholder'), {opacity: 0});
    
    tweens = [];
    
    tweens.push(new TweenMax.to(this.$element.find('.icon__shape--circle-small'), 0.5, {opacity: (!this.level ? 0.2 : 1)}));
    tweens.push(new TweenMax.to(this.$element.find('.icon__shape--circle-big'), 0.5, {opacity: (this.level < 3 ? 0.2 : 1)}));
    tweens.push(new TweenMax.to(this.$element.find('.icon__shape--circle-small'), 0.75, {strokeDashoffset: 0}));
    tweens.push(new TweenMax.to(this.$element.find('.icon__shape--circle-medium'), 0.75, {opacity: (this.level < 2 ? 0.2 : 1), strokeDasharray: '20.42035 163.36281', strokeDashoffset: 0}));
    tweens.push(new TweenMax.to(this.$element.find('.icon__shape--circle-big'), 0.75, {strokeDashoffset: -89.53539}));
    
    this.timeline.add(tweens);
    
    this.gestureManager.off('panstart panmove pancancel panend');
    
    TweenMax.killTweensOf(self.close);
  };
  
  VolumeUIButton.prototype.drag = function () {
    var self = this;
    var volume = 0;
    
    this.gestureManager.on('press', function () {
      TweenMax.to(self.$element.find('.icon__shape--circle-controls'), 0.5, {attr: {r: 10}, opacity: 0.4, ease: Back.easeOut});
      TweenMax.killTweensOf(self.close);
    });
    this.gestureManager.on('panstart', function () {
      volume = self.volume;
    });
    this.gestureManager.on('panmove', function (evt) {
      self.progress = self.volume = Math.min(Math.max(volume + (evt.deltaX * 100 / 125), 0), 100);
      self.refresh();
    });
    
    this.gestureManager.on('pressup', this.release.bind(this));
    this.gestureManager.on('pancancel panend', this.release.bind(this));
    
    TweenMax.delayedCall(3, self.close, null, self);
  };
  
  VolumeUIButton.prototype.release = function () {
    TweenMax.to(this.$element.find('.icon__shape--circle-controls'), 0.5, {attr: {r: 8}, opacity: 0.2});
    TweenMax.delayedCall(3, this.close, null, this);
  };
  
  VolumeUIButton.prototype.refresh = function () {
    var level = 0;
    
    if (this.volume) {
      level = Math.floor(utils.map(this.volume, 0, 101, 0, 3)) + 1;
    }
    
    if (level !== this.level) {
      if (!this.level) {
        this.timeline.clear();
        this.timeline.staggerTo(this.$element.find('.icon__shape--line-mute'), 0.5, {strokeDashoffset: 35.3553}, -0.1);
        this.timeline.staggerTo(this.$element.find('.icon__shape--line-mute'), 0.5, {opacity: 0}, -0.1, 0.25);
      } else if (!level) {
        this.timeline.clear();
        this.timeline.set(this.$element.find('.icon__shape--line-mute'), {opacity: 1});
        this.timeline.staggerTo(this.$element.find('.icon__shape--line-mute'), 0.5, {strokeDashoffset: 0}, 0.1);
      }
      
      this.level = level;
    }
    
    TweenMax.set(this.$element.find('.icon__shape--line-controls.icon__shape--white'), {strokeDashoffset: 125 * (1 - this.progress / 100)});
    TweenMax.set(this.$element.find('.icon__shape--circle-controls'), {x: 125 * this.progress / 100});
    
    this.trigger('volumeChange', this.volume);
  };
  
  return VolumeUIButton;
})();

// DOM
$('.btn--play-pause').each(function () {
  new PlayPauseUIButton($(this));
});
$('.btn--volume').each(function () {
  var btn = new VolumeUIButton($(this));
  
  btn.on('volumeChange', function (vol) {
    console.log(vol);
  });
});

              
            
!
999px

Console