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.

            
              <html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">

  <title>Angular Promise Queue</title>

    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
    <script src="http://www.loringdodge.com/files/angular-promise-queue.js"></script>
  
</head>

  <body ng-app="starter">

    <ion-pane>
      <ion-header-bar class="bar-stable">
        <h1 class="title">Angular Promise Queue</h1>
      </ion-header-bar>
      <ion-content class="padding">

      <p style="text-align:center">A way to queue up promises. In this case...queue up animations</p>

      <button id="start" class="button button-positive">
        Start
      </button>

      <word-slide>
        <div class="slideLeft">This</div>
        <div class="slideRight">is</div>
        <div class="slideLeft">an</div>
        <div class="slideRight">example</div>
        <div class="slideLeft">of</div>
        <div class="slideRight">a</div>
        <div class="slideLeft">promise</div>
        <div class="slideRight">queue</div>
      </word-slide>

      </ion-content>
    </ion-pane>
  </body>

</html>
            
          
!
            
              word-slide {
  margin-top: 50px;
  text-align: center;
}

word-slide div {
  font-size: 24px;
  line-height: 40px;
}

.slideLeft {
  transform: translateX(-30px);
  opacity: 0;
}

.slideRight {
  transform: translateX(30px);
  opacity: 0;
}

.slideLeft.enter, .slideRight.enter {
  transform: translateX(0px);
  opacity: 1;
  transition: all 0.3s ease-out;
}

#start{
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
            
          
!
            
              angular.module('starter', ['ionic', 'promise-queue'])

  .directive('wordSlide', function(PromiseQueue) {

    return {
      restrict: 'E',
      link: function($scope, $element, $attrs) {

        /* Listen for a transition! */
        var transitionEvent = whichTransitionEvent();

        var elements = $element.children();

        var promiseQueue = new PromiseQueue();

        var slideIn = function(el){
          return function(done) {
            angular.element(el).addClass('enter').one(transitionEvent, function(e) {
              done();
            });
          }
        }

        promiseQueue
          .add(slideIn(elements[0]))
          .add(slideIn(elements[1]))
          .add(slideIn(elements[2]))
          .add(slideIn(elements[3]))
          .add(slideIn(elements[4]))
          .add(slideIn(elements[5]))
          .add(slideIn(elements[6]))
          .add(slideIn(elements[7]));

          var startButton = document.getElementById('start');
          angular.element(startButton).on('click', function() {
            promiseQueue.start();
          });

          function whichTransitionEvent(){
            var t;
            var el = document.createElement('fakeelement');
            var transitions = {
              'transition':'transitionend',
              'OTransition':'oTransitionEnd',
              'MozTransition':'transitionend',
              'WebkitTransition':'webkitTransitionEnd'
            }

            for(t in transitions){
              if( el.style[t] !== undefined ){
                return transitions[t];
              }
            }
          }

      }
    }

  });
            
          
!
999px
Loading ..................

Console