<commit_before>// (C) Copyright 2014-2016 Hewlett Packard Enterprise Development LP

import React, { Component, PropTypes } from 'react';
import { findDOMNode } from 'react-dom';
import classnames from 'classnames';
import CSSClassnames from '../utils/CSSClassnames';
import Props from '../utils/Props';
import Responsive from '../utils/Responsive';

const CLASS_ROOT = CSSClassnames.COLUMNS;

export default class Columns extends Component {

  constructor(props, context) {
    super(props, context);
    this._onResize = this._onResize.bind(this);
    this._layout = this._layout.bind(this);
    this.state = {
      count: 1,
      maxCount: this.props.maxCount,
      columnBreakpoints: undefined,
      initMobile: false,
      margin: this.props.margin
    };
  }

  componentDidMount () {
    if (this.props.masonry) {
      this._getColumnBreakpoints();
    }

    window.addEventListener('resize', this._onResize);
    setTimeout(this._layout, 10);
  }

  componentWillUnmount () {
    window.removeEventListener('resize', this._onResize);
    clearTimeout(this._layoutTimer);
    clearTimeout(this._childStylesTimer);
  }

  _onResize () {
    const { initMobile } = this.state;
    if (initMobile) {
      if (window.innerWidth > Responsive.smallSize()) {
        this._getColumnBreakpoints();
      }
    } else {
      clearTimeout(this._layoutTimer);
      this._layoutTimer = setTimeout(this._layout, 50);
    }
  }

  _getChildMarginSize (childStyles) {
    let childMargin;
<commit_msg>Changed Columns to relayout when props change.<commit_after>// (C) Copyright 2014-2016 Hewlett Packard Enterprise Development LP

import React, { Component, PropTypes } from 'react';
import { findDOMNode } from 'react-dom';
import classnames from 'classnames';
import CSSClassnames from '../utils/CSSClassnames';
import Props from '../utils/Props';
import Responsive from '../utils/Responsive';

const CLASS_ROOT = CSSClassnames.COLUMNS;

export default class Columns extends Component {

  constructor(props, context) {
    super(props, context);
    this._onResize = this._onResize.bind(this);
    this._layout = this._layout.bind(this);
    this.state = {
      count: 1,
      maxCount: this.props.maxCount,
      columnBreakpoints: undefined,
      initMobile: false,
      margin: this.props.margin
    };
  }

  componentDidMount () {
    if (this.props.masonry) {
      this._getColumnBreakpoints();
    }

    window.addEventListener('resize', this._onResize);
    setTimeout(this._layout, 10);
  }

  componentWillReceiveProps (nextProps) {
    this.setState({ relayout: true });
  }

  componentDidUpdate () {
    if (this.state.relayout) {
      this.setState({ relayout: false });
      this._layout();
    }
  }

  componentWillUnmount () {
    window.removeEventListener('resize', this._onResize);
    clearTimeout(this._layoutTimer);
    clearTimeout(this._childStylesTimer);
  }

  _onResize () {
    const { initMobile } = this.state;
    if (initMobile) {
      if (window.innerWidth > Responsive.smallSize()) {
        this._getColumnBreakpoints();
      }
    } else {
      clearTimeout(this._layoutTimer);
      this._layoutTimer = setTimeout(this._layout, 50);
    }
  }

  _getChildMarginSize (childStyles) {
    let childMargin;

{'fraction_non_alphanumeric': 0.1205891377723228, 'fraction_numerical': 0.007977907333537895, 'mean_word_length': 3.3699731903485253, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6787916', 'n_tokens_mistral': 993, 'n_tokens_neox': 971, 'n_words': 208}