Code coverage report for lib/prototypes/animations.js

Statements: 23.08% (6 / 26)      Branches: 0% (0 / 6)      Functions: 0% (0 / 6)      Lines: 23.08% (6 / 26)      Ignored: none     

All files » lib/prototypes/ » animations.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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78    1   1                                                         1                 1                       1                         1                    
'use strict';
 
var elements = require('../elements');
 
var _animate = /** @function 
               * @param element 
               * @param animations 
               * @param options */function _animate(element, animations, options) {
    var $element = elements(element);
    if (!$element._animations) {
        $element._animations = [];
    }
 
    var animationPlayer = element.animate(animations, options);
    $element._animations.push(animationPlayer);
    animationPlayer.addEventListener('finish', /** @function */function () {
        var index = $element._animations.indexOf(element);
        $element._animations.splice(index, 1);
        if ($element._animations.length === 0) {
            $element.fire(new Event('animationsFinished'));
        }
    });
    return animationPlayer;
};
 
/**
 * Animate
 *
 * @name Element#animate
 * @method
 * @param {Object} options
 * @return {Element}
 */
elements.addMethodWithArgumentsReturnThis('animate', _animate);
 
/**
 * Animate the opacity from 0 to 1
 * @name Element#fadeOut
 * @method
 * @param {Object} options
 * @return {AnimationPlayer}
 */
elements.addMethodWithArgumentsReturnThis('fadeOut', function (element, options) {
    elements.setStyle(element, 'opacity', 0);
    return _animate(element, [{ opacity: 1 }, { opacity: 0 }], options);
});
 
/**
 * Animate the opacity from 1 to 0
 * @name Element#fadeIn
 * @method
 * @param {Object} options
 * @return {AnimationPlayer}
 */
elements.addMethodWithArgumentsReturnThis('fadeIn', function (element, options) {
    elements.setStyle(element, 'opacity', 1);
    return _animate(element, [{ opacity: 0 }, { opacity: 1 }], options);
});
 
/**
 * Stop any animations for the element
 * @name Element#stop
 * @method
 * @param {HTMLElement} element
 * @param {Object} options
 * @return {AnimationPlayer}
 */
elements.addMethodWithArgumentsReturnThis('stop', function (element, options) {
    var $element = elements(element);
    if (!$element._animations) {
        return;
    }
 
    $element._animations.forEach(function (animationPlayer) {
        return animationPlayer.finish();
    });
});
//# sourceMappingURL=animations.js.map