cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div class="wrapper" ng-app="app">
  <!-- Rotate Button -->
  <div class="button-box">
    <div class="button-box--label">360 Rotate</div>
    <div class="center-position">
      <button class="button refresh" ng-controller="fullRotation" ng-click="fullRotate()">
          <i class="material-icons center-position">autorenew</i>
        </button>
    </div>
  </div>

  <!-- Favorite button -->
  <div class="button-box">
    <div class="button-box--label">Favorite</div>
    <div class="center-position">
      <button class="button heart">
        <img src="http://www.knottaverage.com/img/heart-icon.svg" />
      </button>
    </div>
  </div>

  <div class="button-box">
    <div class="button-box--label">Play / Pause</div>
    <div class="center-position">
      <button class="play-button button play">
        <svg width="100%" height="100%" viewBox="0 0 36 36">
          <defs>
            <path id="pause-icon" data-state="playing" d="M11,10 L17,10 17,26 11,26 M20,10 L26,10 26,26 20,26"></path>
            <path id="play-icon" data-state="paused" d="M11,10 L18,13.74 18,22.28 11,26 M18,13.74 L26,18 26,18 18,22.28"></path>
          </defs>
          <use xlink:href="#play-icon"></use>
        </svg>
      </button>
    </div>
  </div>
</div>
            
          
!
            
              /* General CSS */

body {
  font-family: sans-serif;
  font-size: 1em;
}

.wrapper {
  display: flex;
  flex-wrap: wrap;
}

/* Basic button container*/

.button-box {
  flex: 1;
  width: 300px;
  height: 300px;
  border: solid 1px #fff;
  text-align: center;
  background: #f7f7f7;
  position: relative;
}

.center-position {
  position: absolute;
  margin: auto;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
}

.button-box--label {
  padding: 8px;
  font-size: 1.25em;
  color: #494949;
  font-family: 'Francois One', sans-serif;
}

.button {
  outline: none;
}

.button {
  cursor: pointer;
  width: 60px;
  border-radius: 60px;
  color: #555;
  display: table;
  height: 60px;
  position: absolute;
  margin: auto;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

/* Refresh button */

.refresh {
  border: solid 3px #0cadc9;
  background-color: #16c3e5;
  font-size: 20px;
  box-shadow: 0 1px 1px #999;
}

.material-icons {
  color: #fff;
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  font-size: 36px;
  display: inline-block;
  width: 1em;
  height: 1em;
  line-height: 1;
  text-transform: none;
  letter-spacing: normal;
  word-wrap: normal;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'liga';
}

/* Heart button */

.heart {
  border-radius: 50%;
  border: 0;
  width: 60px;
  height: 60px;
  border: solid 4px #c40000;
  background-color: #ffefef;
  box-shadow: 0 1px 1px #999,
              inset 0 -1px 1px #f7adad;
  transform: scale(1);
  transition: all 1s;
  cursor: pointer;
}

.heart img {
  width: 30px;
  position: relative;
  top: 3px;
}

.heart:hover  img {
  animation: 1300ms pulse infinite alternate ease-in-out;
}

/* Heart animation pulse */
@keyframes pulse {
  0% { 
    transform: scale(1); 
  }
  50% {
    transform: scale(1.1);
  }
  100% { 
    transform: scale(1);
  }
}

/* End Heart */


/* Play / pause */
.play {
  border: solid 3px #1f701f;
  background-color: #36af38;
  box-shadow: 0 1px 1px #999,
              inset 0 0 1px #999;
}

.play-button svg {
  fill: #fff
}
            
          
!
            
              
var app = angular.module('app', []);
var degrees = 360;
var fullRotation = function($scope, $element) {

  $scope.fullRotate = function() {

    var csstransition = '800ms ease';
    var cssrotate = 'rotate(' + degrees + 'deg)';

    $element.children().css({
      '-webkit-transition': csstransition,
      '-moz-transition': csstransition,
      '-o-transition': csstransition,
      'transition': csstransition,
      '-moz-transform': cssrotate,
      '-webkit-transform': cssrotate,
      '-o-transform': cssrotate,
      '-ms-transform': cssrotate
    });
    degrees += 360;
  };

}

console.clear();

var playButton = {
  el: document.querySelector(".play-button"),
  
  states: {
    playing: {
      nextState: "paused",
      iconEl: document.querySelector("#pause-icon")
    },
    paused: {
      nextState: "playing",
      iconEl: document.querySelector("#play-icon")
    }
  },
  
  animationDuration: 350,
  
  init: function () {
    this.setInitialState();
    this.replaceUseEl();
    this.el.addEventListener("click", this.goToNextState.bind(this));
  },
  
  setInitialState: function() {
    var initialIconRef = this.el.querySelector("use").getAttribute("xlink:href");
    var stateName = this.el.querySelector(initialIconRef).getAttribute("data-state");
    this.setState(stateName);
  },
  
  replaceUseEl: function () {
    d3.select(this.el.querySelector("use")).remove();
    d3.select(this.el.querySelector("svg")).append("path")
      .attr("class", "js-icon")
      .attr("d", this.stateIconPath());
    
  },
  
  goToNextState: function () {
    this.setState(this.state.nextState);
    
    d3.select(this.el.querySelector(".js-icon")).transition()
      .duration(this.animationDuration)
      .attr("d", this.stateIconPath());

  },
  
  setState: function (stateName) {
    this.state = this.states[stateName];
  },
  
  stateIconPath: function () {
    return this.state.iconEl.getAttribute("d");
  }
};

playButton.init();
            
          
!
999px
Loading ..................

Console