<commit_before>import Ember from "ember";
import Promise from "liquid-fire/promise";

export default Ember.Component.extend({
  growDuration: 250,
  growPixelsPerSecond: 200,
  growEasing: 'slide',
  lockWidth: false,
  lockHeight: false,
  
  didInsertElement: function() {
    var child = this.$('> div');
    child.css({
      position: 'absolute'
    });
    var css = {
      position: 'relative',
      overflow: 'hidden'
    };
    if (!this.get('lockWidth')) {
      css.width = child.width();
    }
    if (!this.get('lockHeight')) {
      css.height = child.height();
    }
    this.$().css(css);
  },

  sizeChange: Ember.observer('width', 'height', function() {
    var elt = this.$();
    var actions = [];
    if (!this.get('lockWidth')) {
      actions.push(this.adaptDimension(elt, 'width'));
    }
    if (!this.get('lockHeight')) {
      actions.push(this.adaptDimension(elt, 'height'));
    }
    return Promise.all(actions);
  }),

  adaptDimension: function(elt, dimension) {
    var have = elt[dimension]();
    var want = this.get(dimension);
    var target = {};
    target[dimension] = want;

    return Ember.$.Velocity(elt[0], target, {
      duration: this.durationFor(have, want),
      queue: false,
      easing: this.get('growEasing')      
    });
  },

  durationFor: function(before, after) {
    return Math.min(this.get('growDuration'), 1000*Math.abs(before - after)/this.get('growPixelsPerSecond'));
  },

  
});<commit_msg>better liquid-spacer that stays in document flow<commit_after>import Ember from "ember";
import Promise from "liquid-fire/promise";

export default Ember.Component.extend({
  growDuration: 250,
  growPixelsPerSecond: 200,
  growEasing: 'slide',
  
  didInsertElement: function() {
    var child = this.$('> div');
    this.$().css({
      overflow: 'hidden',
      width: child.width(),
      height: child.height()
    });
  },

  sizeChange: Ember.observer('width', 'height', function() {
    var elt = this.$();
    return Promise.all([
      this.adaptDimension(elt, 'width'),
      this.adaptDimension(elt, 'height')
    ]);
  }),

  adaptDimension: function(elt, dimension) {
    var have = elt[dimension]();
    var want = this.get(dimension);
    var target = {};
    target[dimension] = want;

    return Ember.$.Velocity(elt[0], target, {
      duration: this.durationFor(have, want),
      queue: false,
      easing: this.get('growEasing')      
    });
  },

  durationFor: function(before, after) {
    return Math.min(this.get('growDuration'), 1000*Math.abs(before - after)/this.get('growPixelsPerSecond'));
  },

  
});
{'fraction_non_alphanumeric': 0.16904120138621487, 'fraction_numerical': 0.008471313053523296, 'mean_word_length': 3.1369426751592355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5605508', 'n_tokens_mistral': 867, 'n_tokens_neox': 825, 'n_words': 173}