<commit_before>/*
 * accepts: dom element, vertical rhythm int
 * usage: new VerticalRhythm({ image: element, rhythm: 26 });
 */

var VerticalRhythm = function(obj) {
  this.image = obj.image;
  this.rhythm = obj.rhythm;

  if (this.image && this.rhythm) this.init();
};

VerticalRhythm.prototype = {

  /*
    ---------------
    init
    ---------------
  */

  init: function() {
    ['setup'].forEach(this.fire.bind(this));
  },

  fire: function(fn) {
    this[fn]();
  },


  /*
    ---------------
    variables
    ---------------
  */

  currentWidth: 0,

  variables: function() {
    this.originalHeight = this.preloader.height;
    this.originalWidth = this.preloader.width;
    this.ratio = this.originalHeight / this.originalWidth;
  },


  /*
    ---------------
    setup
    ---------------
  */

  setup: function() {
    this.preloader = document.createElement('img');
    this.preloader.onload = function() {
      this.variables();
      this.resize();
    }.bind(this);
    this.preloader.src = this.image.getAttribute('src');
  },


  /*
    ---------------
    utilities
    ---------------
  */

  resize: function() {
    if (this.image.width !== this.currentWidth) {
      this.image.style.height = 'auto';
      this.currentWidth = this.image.width;

      var newHeight = this.currentWidth * this.ratio;
      var clippedHeight = Math.floor(newHeight / this.rhythm) * this.rhythm;

      this.image.style.height = clippedHeight + 'px';
    }
  },

  update: function(rhythm) {
    this.rhythm = rhythm;
    this.currentWidth = 0;

    this.resize();

    console.log(
      this.rhythm
    );
  }

};<commit_msg>Removing stray console.log<commit_after>/*
 * accepts: dom element, vertical rhythm int
 * usage: new VerticalRhythm({ image: element, rhythm: 26 });
 */

var VerticalRhythm = function(obj) {
  this.image = obj.image;
  this.rhythm = obj.rhythm;

  if (this.image && this.rhythm) this.init();
};

VerticalRhythm.prototype = {

  /*
    ---------------
    init
    ---------------
  */

  init: function() {
    ['setup'].forEach(this.fire.bind(this));
  },

  fire: function(fn) {
    this[fn]();
  },


  /*
    ---------------
    variables
    ---------------
  */

  currentWidth: 0,

  variables: function() {
    this.originalHeight = this.preloader.height;
    this.originalWidth = this.preloader.width;
    this.ratio = this.originalHeight / this.originalWidth;
  },


  /*
    ---------------
    setup
    ---------------
  */

  setup: function() {
    this.preloader = document.createElement('img');
    this.preloader.onload = function() {
      this.variables();
      this.resize();
    }.bind(this);
    this.preloader.src = this.image.getAttribute('src');
  },


  /*
    ---------------
    utilities
    ---------------
  */

  resize: function() {
    if (this.image.width !== this.currentWidth) {
      this.image.style.height = 'auto';
      this.currentWidth = this.image.width;

      var newHeight = this.currentWidth * this.ratio;
      var clippedHeight = Math.floor(newHeight / this.rhythm) * this.rhythm;

      this.image.style.height = clippedHeight + 'px';
    }
  },

  update: function(rhythm) {
    this.rhythm = rhythm;
    this.currentWidth = 0;

    this.resize();
  }

};
{'fraction_non_alphanumeric': 0.21463714637146372, 'fraction_numerical': 0.0024600246002460025, 'mean_word_length': 1.8992869875222815, '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': '3688909', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1012, 'n_words': 176}