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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <html ng-app="app">
  <head>
    <title>Title of the document</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.6/angular-material.css">

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-aria.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-messages.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.0.6/angular-material.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.2/TweenMax.min.js"></script>
  </head>

  <body layout="column" ng-cloak>
    <main layout="column" flex ng-controller="MainController as vm">

      <md-whiteframe class="md-whiteframe-1dp section">
        <step-list steps="vm.steps" current="{{vm.currentIndex}}" layout="row" layout-align="space-around">
        </step-list>
      </md-whiteframe>

      <md-whiteframe class="md-whiteframe-1dp section">
        <md-button class="md-primary md-raised md-hue-1" ng-click="vm.prevStep()">Previous</md-button>
        <md-button class="md-primary md-raised md-hue-1" ng-click="vm.nextStep()">Next</md-button>
      </md-whiteframe>    
    </main>

    <script type="text/ng-template" id="step-list.html">
      <step-progress ng-repeat="step in $ctrl.steps" index="{{$index}}"></step-progress>
      <step-cursor class="cursor"></step-cursor>
    </script>

    <script type="text/ng-template" id="step-progress.html">
      <md-button class="md-fab" ng-disabled="true">{{$ctrl.index}}</md-button>
    </script>

    <script type="text/ng-template" id="step-cursor.html">
      <md-button class="md-fab">{{$ctrl.index}}</md-button>
    </script>  
  </body>
</html>
              
            
!

CSS

              
                .section {
  margin: 15px;
  padding: 15px;
}

step-cursor {
  position: absolute;
  top: 0;
  left: 0;  
  z-index: 10;
}
              
            
!

JS

              
                console.clear();
var log = console.log.bind(console);

//
// MAIN CONTROLLER
// ===========================================================================
class MainController {
  
  constructor() {
    
    // step data... whatever
    this.steps = [
      { id: 0 },
      { id: 1 },
      { id: 2 },
      { id: 3 },
      { id: 4 }
    ];
    
    this.currentIndex = 0;
  }
  
  nextStep() {
    this.currentIndex = Math.min(this.currentIndex + 1, this.steps.length - 1);
  }
  
  prevStep() {   
    this.currentIndex = Math.max(this.currentIndex - 1, 0);
  }
}

//
// STEP LIST
// ===========================================================================
class StepList {
  
  constructor($element, $scope, $animate, $timeout) {
    
    this.cursor = null;
    this.animation = null;
    
    this.$scope = $scope;
    this.$timeout = $timeout;    
    this.$element = $element;
    this.$animate = $animate;        
  }
  
  addCursor(cursor) {
    
    this.cursor = cursor;
    
    this.$scope.$watch(() => this.current, (step) => {      
      this.moveCursor(+step);
    });   
  }
  
  moveCursor(step, first) {
    
    if (!this.cursor) return;
    
    // Cancel current animation
    if (this.animation) {
      this.$animate.cancel(this.animation);
    }
    
    var icon = this.cursor.$element[0];    
    var dest = this.$element.children()[step];
        
    var rect1 = dest.getBoundingClientRect();
    var rect2 = icon.getBoundingClientRect();
        
    var x = `+=${rect1.left - rect2.left}`;
    var y = `+=${rect1.top  - rect2.top}`;
    
    this.animation = this.$animate.animate(icon, {}, { x, y });    
  }
}

var stepList = {  
  controller: StepList,
  templateUrl: "step-list.html",
  bindings: {
    current: "@",
    steps: "="
  }
};

//
// STEP PROGRESS
// ===========================================================================
var stepProgress = {
  templateUrl: "step-progress.html",
  bindings: {
    index: "@"
  }
};

//
// STEP CURSOR
// ===========================================================================
class StepCursor {
  
  constructor($element, $timeout) {
    
    this.$element = $element;
    
    TweenLite.set($element, { autoAlpha: 0 });
        
    $timeout(() => {
      this.parent.addCursor(this);
      TweenLite.to(this.$element, 1, { autoAlpha: 1 });
    });
  }
}

var stepCursor = {
  controller: StepCursor,
  templateUrl: "step-cursor.html",
  require: {
    parent: "^stepList"
  }
};

//
// CURSOR ANIMATION
// ===========================================================================
function cursorAnimation() {
  
  var tween = null;
  
  return {        
    animate: (element, from, to, done) => {
            
      var time = tween ? 0.5 : 0;     
      tween && tween.kill();
            
      tween = TweenLite.to(element, time, { x: to.x, y: to.y, onComplete: done });      
    }
  };
}

//
// MODULE
// ===========================================================================
angular
  .module('app', ["ngMaterial"])
  .animation(".cursor", cursorAnimation)
  .component("stepProgress", stepProgress)
  .component("stepList", stepList)
  .component("stepCursor", stepCursor)
  .controller("MainController", MainController);


              
            
!
999px

Console