Source: tween.js

define(['eventmap', 'mixedice', 'options', 'jqueryify'], function(EventMap, mixedice, options, $fy) {
  'use strict';
  
  /**
   * @module lyria/tween
   * @requires eventmap
   * @requires mixedice
   * @requires options
   * @requires jqueryify 
   */
  
  var Tween = (function() {
    
    /**
     * @class
     * @alias module:lyria/tween
     * 
     * @param {Object} opts
     */
    var Tween = function(opts) {
      opts = options(opts, {
        elem: null,
        effects: [{
          property: null,
          target: null,
          easing: Tween.defaults.easing,
          duration: Tween.defaults.duration,
          delay: Tween.defaults.delay
        }]
      });
      
      this.$elem = $fy(opts.elem);
      this.effects = opts.effects;

      this.hwAccelerated = true;

      mixedice([this, Tween.prototype], new EventMap());

      var self = this;

      this.on('start', function() {
        if (self.$elem) {
          return;
        }
        
        var effects = [];
        var properties = {};
        
        for (var i = 0, j = self.effects.length; i < j; i++) {
          (function(item) {
            if (item.property == null || item.target == null) {
              return;
            }
            
            item.duration = item.duration || Tween.defaults.duration;
            item.easing = item.easing || Tween.defaults.easing;
            item.delay = item.delay || Tween.defaults.delay;
            
            effects.push([item.property, item.duration, item.easing, item.delay].join(' '));
            properties[item.property] = item.target;
          })(self.effects[i]);
        }
        
        properties['transition'] = effects.join(', ');
        self.$elem.css(properties);
        
        $(document).one('transitionend', function(e) {
          console.log(e.target);
        });
      });
    };
    
    /**
     * @member module:lyria/tween.defaults 
     */
    Tween.defaults = {
      easing: 'linear',
      duration: '300ms',
      delay: '0ms'
    };

    return Tween;
  })();

  return Tween;
}); 
DocStrap Copyright © 2012-2013 The contributors to the JSDoc3 and DocStrap projects.
Documentation generated by JSDoc 3.2.2 on Sun Jan 26 2014 20:12:45 GMT+0100 (MEZ) using the DocStrap template.