function _changeOpacity(_el, value, time) {
  // rate of change
  var fps = 24;
  var time_per_frame = time / fps;
  // current opacity
  var current_opacity = parseFloat(_el.style.opacity) || 0;
  // change for opacity
  var diff = value - current_opacity;
  var delta = diff / time_per_frame;

  // Return a promise so we know when this is done
  return new Promise(function (resolve, reject) {
    var interval = setInterval(change, time_per_frame);
    function change() {
      // Set new opacity
      current_opacity += delta;
      current_opacity = current_opacity < 0 ? 0 : current_opacity;
      current_opacity = current_opacity > 1 ? 1 : current_opacity;
      _el.style.opacity = current_opacity;
      // Check if done
      if (current_opacity === 1 || current_opacity === 0) {
        // End interval and resolve the promise
        clearInterval(interval);
        resolve();
      }
    }
  });
}
// Returns a promise to use for completion
Returns a promise to use for completion
Returns a promise to use for completion
function _changeOpacity(_el, value, time) {
  var fps = 24;
  var time_per_frame = time / fps;
  var current_opacity = parseFloat(_el.style.opacity) || 0;
  var diff = value - current_opacity;
  var delta = diff / time_per_frame;
  return new Promise(function (resolve, reject) {
    var interval = setInterval(change, time_per_frame);
    function change() {
      current_opacity += delta;
      current_opacity = current_opacity < 0 ? 0 : current_opacity;
      current_opacity = current_opacity > 1 ? 1 : current_opacity;
      _el.style.opacity = current_opacity;
      if (current_opacity === 1 || current_opacity === 0) {
        clearInterval(interval);
        resolve();
      }
    }
  });
}
function _changeOpacity ( _el , value , time ) { var fps = 24 ; var time_per_frame = time / fps ; var current_opacity = parseFloat ( _el . style . opacity ) || 0 ; var diff = value - current_opacity ; var delta = diff / time_per_frame ; return new Promise ( function ( resolve , reject ) { var interval = setInterval ( change , time_per_frame ) ; function change ( ) { current_opacity += delta ; current_opacity = current_opacity < 0 ? 0 : current_opacity ; current_opacity = current_opacity > 1 ? 1 : current_opacity ; _el . style . opacity = current_opacity ; if ( current_opacity === 1 || current_opacity === 0 ) { clearInterval ( interval ) ; resolve ( ) ; } } } ) ; }
Returns a promise to use for completion
Returns a promise to use for completion
// rate of change // current opacity // change for opacity // Return a promise so we know when this is done // Set new opacity // Check if done // End interval and resolve the promise