<commit_before>
// IMPROVE: Transparently handle dimensions (em, px, %, etc)?

var Fx = function(element, styles, options)
{
  this.element = element;
  this.styles  = styles;
  this.options = Object.merge(this.options, options);
  
  this.occurences = this.options.duration / 1000 * this.options.interval;
  this.transition = Fx.transitions[this.options.transition];
}

Fx.prototype.options = {
  duration: 500,
  transition: 'linear',
  interval: 40
};

Fx.prototype.run = function()
{
  this.element.setStyle(this.nextStyles);
  
  if (++this.frame < this.occurences)
  {
    setTimeout(this.run.bind(this), 1000 / this.options.interval);
    this.computeNextIncrement(this.frame);
  }
}

Fx.prototype.setInitialState = function()
{
  this.nextStyles = [];
  for (var s in this.styles)
  {
    if (!(this.styles[s] instanceof Array))
    {
      var v = this.element.getStyle(s).replace('px', '');
      this.styles[s]     = [v, this.styles[s]];
      this.nextStyles[s] = [v, this.styles[s]];
    }
  }<commit_msg>Added onComplete callback to Fx.<commit_after>
// IMPROVE: Transparently handle dimensions (em, px, %, etc)?

var Fx = function(element, styles, options)
{
  this.element = element;
  this.styles  = styles;
  this.options = Object.merge(this.options, options);
  
  this.occurences = this.options.duration / 1000 * this.options.interval;
  this.transition = Fx.transitions[this.options.transition];
}

Fx.prototype.options = {
  duration: 500,
  transition: 'linear',
  interval: 40,
  onComplete: function() {}
};

Fx.prototype.run = function()
{
  this.element.setStyle(this.nextStyles);
  
  if (++this.frame < this.occurences)
  {
    setTimeout(this.run.bind(this), 1000 / this.options.interval);
    this.computeNextIncrement(this.frame);
  }
  else {
    this.options.onComplete();
  }
}

Fx.prototype.setInitialState = function()
{
  this.nextStyles = [];
  for (var s in this.styles)
  {
    if (!(this.styles[s] instanceof Array))
    {
      var v = this.element.getStyle(s).replace('px', '');
      this.styles[s]     = [v, this.styles[s]];
      this.nextStyles[s] = [v, this.styles[s]];
    }
  }
{'fraction_non_alphanumeric': 0.16071428571428573, 'fraction_numerical': 0.012218045112781954, 'mean_word_length': 3.4446764091858038, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4062973', 'n_tokens_mistral': 766, 'n_tokens_neox': 746, 'n_words': 136}