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

              
                <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.16.6/lodash.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/TweenMax.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/gsap/1.19.0/plugins/ScrollToPlugin.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-animate.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-aria.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-sanitize.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-resource.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.1/angular-material.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-material-icons/0.7.1/angular-material-icons.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.3.2/angular-ui-router.min.js"></script>
<script src="//s3-us-west-2.amazonaws.com/s.cdpn.io/106114/videogular.js"></script>
<script src="//s3-us-west-2.amazonaws.com/s.cdpn.io/106114/vg-controls.js"></script>
<script src="//s3-us-west-2.amazonaws.com/s.cdpn.io/106114/vg-overlay-play.js"></script>
<script src="//s3-us-west-2.amazonaws.com/s.cdpn.io/106114/vg-poster.js"></script>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.1/angular-material.css" />

<body ng-app="app" ng-cloak>
  <main ng-controller="MainController as vm" layout="column" layout-fill>
    
    <md-toolbar class="toolbar" md-colors="{background: 'default-primary-900'}">
      <div class="md-toolbar-tools">
        <md-button class="md-icon-button" ng-disabled="true">
          <ng-md-icon icon="menu" size="24"></ng-md-icon>
        </md-button>
        <h2>
          <span class="md-flex">{{vm.appName}}</span>
        </h2>
        <span flex></span>
      </div>      
    </md-toolbar>
    
    <md-tabs class="tab-bar" md-colors="{background: 'default-primary-900'}" md-selected="vm.selectedIndex">
      <md-tab ng-disabled="!vm.ready">
        <md-tab-label class="tab-label">Heroes</md-tab-label>
      </md-tab>
      <md-tab  ng-disabled="!vm.ready">
        <md-tab-label>Demos</md-tab-label>
      </md-tab>
      <md-tab  ng-disabled="!vm.ready">
        <md-tab-label>About</md-tab-label>
      </md-tab>
    </md-tabs>
    
    <div class="view-container" flex>
      
      <md-content class="view-animation" ng-if="vm.ready" ui-view></md-content>
      
      <div class="loading-animation" layout="row" layout-sm="column" layout-align="space-around" ng-if="!vm.ready">
        <md-progress-circular class="circular-progress"></md-progress-circular>
      </div>
    </div>

    <aside id="templates" style="display:none">
    
      <!-- HEROES.HTML -->
      <section id="heroes-template">
        
        <div layout="row" layout-wrap layout-margin>
            <md-card class="click-card animation-card" 
                     ng-repeat="hero in vm.heroes" 
                     ng-click="vm.redirectTo(hero.username)">
              <md-card-title>
                <md-card-title-text>
                  <span class="md-headline">{{hero.nicename}}</span>
                  <span class="md-subhead card-subhead">Followers {{hero.followers}}</span>
                </md-card-title-text>
              </md-card-title>
              <md-card-content layout="row" layout-align="space-between">
                <div class="md-media-xl card-media" layout-align="center center">              
                  <img class="profile-image" ng-src="{{hero.avatar}}" />
                </div>
              </md-card-content>
            </md-card>
        </div>        
      </section>
      
      <!-- DEMOS.HTML -->
      <section id="demos-template">
        
        <div layout="row" layout-wrap layout-margin>
          <md-card class="click-card animation-card pen-card" 
                   ng-repeat="pen in vm.demos | limitTo: vm.penLimit" 
                   ng-click="vm.redirectTo('pen/' + pen.id)">
            <md-card-title>
              <md-card-title-text>
                <span class="md-headline pen-headline" ng-bind-html="pen.title"></span>
                <span class="md-subhead card-subhead">{{pen.user.nicename}}</span>
                <span class="md-subhead card-subhead">Views {{pen.views}}</span>
              </md-card-title-text>
            </md-card-title>
            <md-card-content layout="row" layout-align="space-between">
              <div class="md-media-xl card-media pen-media" layout-align="center center">              
                <img class="pen-image" ng-src="{{pen.images.large}}" />
              </div>
            </md-card-content>
          </md-card>
        </div>        
      </section>
      
      <!-- VIDEOS.HTML -->
      <section id="videos-template">        
        
        <div layout="row" layout-wrap layout-margin layout-align="center start">
        
          <md-card class="animation-card video-card" ng-repeat="video in vm.videos">
            <md-card-content class="video-content">   
              
              <div class="video-container">                
                <videogular vg-theme="vm.config.theme">
                  <vg-media class="embed-responsive embed-responsive-16by9" vg-src="video.sources"></vg-media>
                  
                  <vg-controls>
                    <vg-play-pause-button></vg-play-pause-button>
                    <vg-time-display>{{ currentTime | date:'mm:ss':'+0000' }}</vg-time-display>
                    <vg-scrub-bar>
                      <vg-scrub-bar-current-time></vg-scrub-bar-current-time>
                    </vg-scrub-bar>
                    <vg-time-display>{{ timeLeft | date:'mm:ss':'+0000' }}</vg-time-display>
                    <vg-time-display>{{ totalTime | date:'mm:ss':'+0000' }}</vg-time-display>
                    <vg-volume>
                      <vg-mute-button></vg-mute-button>
                      <vg-volume-bar></vg-volume-bar>
                    </vg-volume>
                    <vg-fullscreen-button></vg-fullscreen-button>
                  </vg-controls>

                  <vg-overlay-play></vg-overlay-play>
                  <vg-poster vg-url="video.poster"></vg-poster>                 
                </videogular>             
              </div>                
            </md-card-content>
          </md-card>          
          </div>     
      </section>
      
    </aside>        
  </main>
</body>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

main {
  position: relative;
  width: 100vw;
  height: 100vh;  
  overflow: hidden;
}

.view-container {
  background: #eee;
  position: relative;
}

md-tab-item {
  color: rgba(255,255,255,0.64) !important;
}

.view-animation {
  position: absolute;
  width: 100%;
  height: 100%;
  
  background: transparent;
}

.click-card {
  cursor: pointer;
}

.card-subhead {
  padding: 0 !important;
}

.pen-card {
  max-width: 400px;
  width: 100%;
}

.pen-headline {
  max-width: 365px;
  text-overflow: ellipsis;
  white-space: nowrap; 
  overflow: hidden; 
}

.pen-card md-card-title-text {
  overflow: hidden;
}

.pen-image {
  width: 100%;
}

.pen-media {
  width: 384px !important;
  height: 225px !important;
}

.video-container {
  width: 100%;
}

.video-card {  
  width: 100%;
}

.video-content {
  padding: 0;
}

.loading-animation {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);  
  z-index: 10000;
}

.embed-responsive {
  position: relative;
  display: block;
  height: 0;
  padding: 0;
  overflow: hidden;
}

.embed-responsive.embed-responsive-16by9 {
  padding-bottom: 56.25%;
}

.embed-responsive.embed-responsive-16by9 video {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.toolbar .md-button ng-md-icon {
  fill: rgba(255,255,255,0.87);
}

.toolbar .md-button[disabled] ng-md-icon {
  fill: rgba(255,255,255,0.26);
}

.tab-bar md-ink-bar {
  height: 4px;
}

md-tabs.tab-bar md-ink-bar {
  color: rgb(127,212,28);
  background: rgb(127,212,28);
}

md-progress-circular.circular-progress path {
  stroke: rgb(127,212,28);
}

@media (min-width: 1200px) {
  
  .video-card {
    width: 1170px;    
    height: 658.125px;
  }
}

@media (min-width: 992px) and (max-width: 1199px) {  
  
  .video-card {
    width: 940px;    
    height: 528.75px;
  }
}

@media (min-width: 768px) and (max-width: 991px) {  
  
  .video-card {
    width: 728px;    
    height: 409.5px;
  }
}
              
            
!

JS

              
                namespace App {
  
  console.clear();  
  var log = console.log.bind(console);
    
  var baseUrl = "https://s3-us-west-2.amazonaws.com/s.cdpn.io/106114/";
  var gsapUrl = "https://s3.amazonaws.com/greensock/video/";
    
  var config = {        
    appName: "GSAP Tour",
    heroes: [
      "GreenSock",
      "osublake",
      "dipscom",
      "jonathan",
      "MAW",
      "rhernando",
      "ihatetomatoes",
      "PointC",
      "tah_med",
      "chrisgannon",
      "sdras",
      "bassta",
      "Zeaklous",
      "joemidi",
      "petebarr"
    ],    
    theme: baseUrl + "videogular.css",
    videos: [{
      poster: baseUrl + "what-is-gsap-poster.jpg",
      sources: [
        { src: gsapUrl + "gsap-explainer-high.mp4",  type: "video/mp4"  },
        { src: gsapUrl + "gsap-explainer-high.webm", type: "video/webm" }
      ]
    }, {
      poster: baseUrl + "what-is-club-greensock.jpg",
      sources: [
        { src: gsapUrl + "club-explainer-high.mp4",  type: "video/mp4"  },
        { src: gsapUrl + "club-explainer-high.webm", type: "video/webm" }
      ]
    }],    
    accentPalette: "light-green",
    primaryPalette: "grey",
    penLimit: 30,
  };
    
  function configureApp($mdThemingProvider, $stateProvider, $urlRouterProvider, config) {
    
    $mdThemingProvider
      .theme("default")
      .primaryPalette(config.primaryPalette)
      .accentPalette(config.accentPalette);
    
    $stateProvider
      .state("heroes", {
        url: "/heroes",
        template: $("#heroes-template").html()
      })
      .state("demos", {
        url: "/demos",
        template: $("#demos-template").html()
      })
      .state("videos", {
        url: "/videos",
        template: $("#videos-template").html()
      });

    $urlRouterProvider.otherwise("/heroes");   
  }
  
  function viewAnimation($state) {    
        
    var zIndex  = 1;
    var stagger = 0.04;
    
    var leaveDelay = 0.2;
    var enterDelay = 0.3;
    
    var leaveOffset = 50;
    var enterOffset = 50;
    
    var leaveDuration = 0.35;
    var enterDuration = 0.4;    
    
    var ease = Sine.easeOut;
    var wait = (leaveDuration + leaveDelay) + 0.25;    
    
    return {
      enter: (element, done) => {       
             
        var cards = element.find(".animation-card");  
        
        var tl = new TimelineLite({ onComplete: done })
          .set(cards, { yPercent: enterOffset, autoAlpha: 0, zIndex: zIndex++ })       
          .staggerTo(cards, enterDuration, { yPercent: 0, autoAlpha: 1, ease }, stagger, enterDelay)               
      },
      leave: (element, done) => {
                        
        var cards = element.find(".animation-card");        
        var tl = new TimelineLite({ onComplete: done })
          .staggerTo(cards, leaveDuration, { yPercent: leaveOffset, autoAlpha: 0, ease }, stagger, leaveDelay);
      }
    }
  }
  
  function loadingAnimation() {
    return { leave: (element, done) => TweenLite.to(element, 0.75, { autoAlpha: 0, onComplete: done }) };
  }
    
  class CodePen {
    
    config = {
      cache: true,
      timeout: 5000
    };
    
    constructor(public $http, public $q, public codePenUrl) {
      
    }
    
    getProfiles(users) {
      
      return this.$q.all(
        users.map(user => this.$http.get(`${this.codePenUrl}profile/${user.username}`, this.config)))
        .then(results => {

          return results.reduce((profiles, result) => {

            var data = result.data.data;

            if (data) {
              profiles.push(data);           
              var user = _.find(users, user => _.lowerCase(user.username) === _.lowerCase(data.username));     
              if (user) { user.nicename = data.nicename; }
            }

            return profiles
          }, []);
        })
        .catch(error => console.error("GET PROFILE", error));
    }
        
    getPens(users, category) {
      
      var penData = [];
      
      return this.$q.all(users.map(
        user => this.$http.get(`${this.codePenUrl}pens/${category}/${user.username}`, this.config)))
        .then(results => {

          return results.reduce((pens, result) => {

            var data = result.data.data;

            if (data) {
              pens.push(...data);              
              var user = _.find(users, user => _.lowerCase(user.username) === _.lowerCase(data[0].user.username));
              if (user) { _.forEach(data, pen => pen.user.nicename = user.nicename); }            
            }      

            return pens;
          }, penData);
        })
        .catch(error => console.error("GET PENS", error));
    }
  }
    
  class MainController {
    
    ready = false;
    users = [];
    demos = [];
    heroes = [];
    theme = this.config.theme;
    videos = this.config.videos;
    appName = this.config.appName;
    penLimit = this.config.penLimit;
    selectedIndex = 0;

    constructor(
      public $sce,
      public $scope, 
      public $state, 
      public $timeout, 
      public $window, 
      public codePen, 
      public config) {
            
      this.users = this.config.heroes.map((username => ({ username, nicename: "" })));
      
      config.videos.forEach(video => {
        video.sources.forEach(file => {          
          file.src = $sce.trustAsResourceUrl(file.src);
        });
      });      
            
      codePen.getProfiles(this.users)
        .then(response => this.heroes = _.shuffle([...response]))
        .then(() => codePen.getPens(this.users, "popular"))
        .then(response => this.demos = _.shuffle([...response]))
        .catch(error => console.error("LOAD ERROR", error))
        .finally(() => $timeout(() => { this.ready  = true; }, 150));
           
      $scope.$watch(() => this.selectedIndex, index => {        
        switch(index) {
          case 0: $state.transitionTo("heroes"); break;
          case 1: $state.transitionTo("demos");  break;
          case 2: $state.transitionTo("videos"); break;
        }        
      });      
    }

    redirectTo(param) {
      this.$window.open("https://codepen.io/" + param, "_blank");
    }
  }

  angular
    .module("app", [
      "ngSanitize",
      "ngMaterial",
      "ngMdIcons",
      "ui.router",
			"com.2fdevs.videogular",
			"com.2fdevs.videogular.plugins.controls",
			"com.2fdevs.videogular.plugins.overlayplay",
			"com.2fdevs.videogular.plugins.poster"
    ])
    .animation(".view-animation", viewAnimation)
    .animation(".loading-animation", loadingAnimation)
    .config(configureApp)
    .constant("config", config)
    .controller("MainController", MainController)
    .service("codePen", CodePen)
    .value("codePenUrl", "https://cpv2api.com/");
}


              
            
!
999px

Console