<commit_before>(function (root, factory) {
  if (typeof define === 'function' && define.amd) {
    define([], function () {
      return factory();
    });
  } else if (typeof exports !== 'undefined') {
    module.exports = factory();
  } else {
    root.motioncontrol = factory();
  }

}(this, function () {
  'use strict';

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

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

  var motioncontrol = (function () {
    return function (el, options) {
      var resolver = {};
      var opts = options || {};
      var trigger = opts.trigger && _.isFunction (opts.trigger) ? opts.trigger :  null;

      var event = transitionEvent();

      var motionComplete = function () {
        el.removeEventListener(event, motionComplete, false);

        // resolve promise
        resolver.resolve();

        // clean references
        resolver = null;
      };

      // search for an existing promise
      var PromiseFn = motioncontrol.Promise || (typeof Promise !== null && Promise);

      var motion = PromiseFn && new PromiseFn(function (resolve, reject) {
        resolver = {
          resolve: resolve,
          reject: reject
        };
      });
      
      // add listeners
      el.addEventListener(event, motionComplete, false);

      if (trigger) {
        trigger();
      }

      return motion;
    };
  })();
<commit_msg>feat(timeout): add a timeout to fake transitionend<commit_after>(function (root, factory) {
  if (typeof define === 'function' && define.amd) {
    define([], function () {
      return factory();
    });
  } else if (typeof exports !== 'undefined') {
    module.exports = factory();
  } else {
    root.motioncontrol = factory();
  }

}(this, function () {
  'use strict';

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

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

  var motioncontrol = (function () {
    return function (el, options) {
      var resolver = {};
      var opts = options || {};
      var trigger = opts.trigger && _.isFunction (opts.trigger) ? opts.trigger :  null;
      var timeout = opts.timeout || 1000;

      var event = transitionEvent();

      var motionComplete = function () {
        el.removeEventListener(event, motionComplete, false);

        // resolve promise
        resolver.resolve();

        // clean references
        resolver = null;
      };

      // search for an existing promise
      var PromiseFn = motioncontrol.Promise || (typeof Promise !== null && Promise);

      var motion = PromiseFn && new PromiseFn(function (resolve, reject) {
        resolver = {
          resolve: resolve,
          reject: reject
        };
      });

      // add listeners
      el.addEventListener(event, motionComplete, false);

      if (trigger) {
        trigger();
      }

      // add a timeout in case where the transitionend event would not be fired
      // which basically make this library :
      // * fake non CSS3 browsers or
      // * fake a transition end if the property is removed
      setTimeout(motionComplete, timeout);

      return motion;
    };
  })();

{'fraction_non_alphanumeric': 0.1276878152375896, 'fraction_numerical': 0.0013273161667109105, 'mean_word_length': 2.2937062937062938, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3668941', 'n_tokens_mistral': 1008, 'n_tokens_neox': 976, 'n_words': 284}