# Code coverage report for lib/template/view/transitions.js

## Statements: 85% (17 / 20) Branches: 62.5% (5 / 8) Functions: 100% (6 / 6) Lines: 87.5% (14 / 16) Ignored: none

All files » lib/template/view/ » transitions.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    491

    1
    261
    261

    1

    1
    1

    310

    24
    1
    1
    1
    1

    1

     var protoclass = require("protoclass"),
    async          = require("../../utils/async");

    /**
     */

    function Transitions() {
      this._enter = [];
      this._exit  = [];
    }

    /**
     */

    module.exports = protoclass(Transitions, {

      /**
       */

      push: function(transition) {
        Iif (transition.enter) this._enter.push(transition);
        Eif (transition.exit) this._exit.push(transition);
      },

      /**
       */

      enter: function() {
        Eif (!this._enter.length) return false;
        for (var i = 0, n = this._enter.length; i < n; i++) {
          this._enter[i].enter();
        }
      },

      /**
       */

      exit: function(complete) {
        if (!this._exit.length) return false;
        var self = this;
        process.nextTick(function() {
          async.each(self._exit, function(transition, next) {
            transition.exit(next);
          }, complete);
        });

        return true;
      }
    });