<commit_before>import React, { Component, PropTypes } from 'react';
import { ListView, ScrollView, View, Platform } from 'react-native';
import YYListViewCell from './YYListViewCell';

const isIOS = Platform.OS === 'ios';

const propTypes = {
  ...ListView.propTypes,
  renderScrollComponent: PropTypes.func,
  scrollRenderAheadDistance: PropTypes.number,
};

const defaultProps = {
  ...ListView.defaultProps,
  scrollRenderAheadDistance: 0,
};

class YYListView extends Component {
  constructor(props) {
    super(props);

    this.sections = {};
    this.rows = {};
    this.separators = {};
    this.cells = [];
    this.cellOffsets = [];
    this.nativeListView = null;

    this.onCellLayout = this.onCellLayout.bind(this);
    this.onScroll = this.onScroll.bind(this);
    this.renderScrollComponent = this.renderScrollComponent.bind(this);
    this.renderSectionHeader = this.renderSectionHeader.bind(this);
    this.renderRow = this.renderRow.bind(this);
    this.renderSeparator = this.renderSeparator.bind(this);
  }

  /**
   * Cell layout event callback
   * Recalculate cells' offsets when cell layout event triggered
   */
  onCellLayout() {
    this.calcCellOffsets();
  }

  /**
   * ListView scroll event callback.
   * We update the cells' visibility each time scroll event is triggered
   */
  onScroll(e) {
        // Calculate the current content offsets
    const contentOffsetX = e.nativeEvent.contentOffset.x - this.props.scrollRenderAheadDistance;
    const contentOffsetY = e.nativeEvent.contentOffset.y - this.props.scrollRenderAheadDistance;
    const layoutMeasurementWidth = e.nativeEvent.layoutMeasurement.width + this.props.scrollRenderAheadDistance;
    const layoutMeasurementHeight = e.nativeEvent.layoutMeasurement.height + this.props.scrollRenderAheadDistance;
    const currentOffset = [
      this.props.horizontal ? contentOffsetX : contentOffsetY,
      this.props.horizontal ? (contentOffsetX + layoutMeasurementWidth)
                            : (contentOffsetY + layoutMeasurementHeight),
    ];

        // Calculate the range of visible cells.
    const cellOffsets = this.cellOffsets;
    let visibleStart = 0;

    while (cellOffsets[visibleStart++] < currentOffset[0]);
    visibleStart--;

    let visibleEnd = visibleStart;
    while (cellOffsets[visibleEnd++] <= currentOffset[1]);
    visibleEnd--;

        // Update cells' visibility<commit_msg>Fix eslint errors<commit_after>import React, { Component, PropTypes } from 'react';
import { ListView, ScrollView, View, Platform } from 'react-native';
import YYListViewCell from './YYListViewCell';

const isIOS = Platform.OS === 'ios';

const propTypes = {
  ...ListView.propTypes,
  renderScrollComponent: PropTypes.func,
  scrollRenderAheadDistance: PropTypes.number,
};

const defaultProps = {
  ...ListView.defaultProps,
  scrollRenderAheadDistance: 0,
};

class YYListView extends Component {
  constructor(props) {
    super(props);

    this.sections = {};
    this.rows = {};
    this.separators = {};
    this.cells = [];
    this.cellOffsets = [];
    this.nativeListView = null;

    this.onCellLayout = this.onCellLayout.bind(this);
    this.onScroll = this.onScroll.bind(this);
    this.renderScrollComponent = this.renderScrollComponent.bind(this);
    this.renderSectionHeader = this.renderSectionHeader.bind(this);
    this.renderRow = this.renderRow.bind(this);
    this.renderSeparator = this.renderSeparator.bind(this);
  }

  /**
   * Cell layout event callback
   * Recalculate cells' offsets when cell layout event triggered
   */
  onCellLayout() {
    this.calcCellOffsets();
  }

  /**
   * ListView scroll event callback.
   * We update the cells' visibility each time scroll event is triggered
   */
  onScroll(e) {
        // Calculate the current content offsets
    const { scrollRenderAheadDistance } = this.props;
    const { contentOffset, layoutMeasurement } = e.nativeEvent;
    const contentOffsetX = contentOffset.x - scrollRenderAheadDistance;
    const contentOffsetY = contentOffset.y - scrollRenderAheadDistance;
    const layoutMeasurementWidth = layoutMeasurement.width + scrollRenderAheadDistance;
    const layoutMeasurementHeight = layoutMeasurement.height + scrollRenderAheadDistance;
    const currentOffset = [
      this.props.horizontal ? contentOffsetX : contentOffsetY,
      this.props.horizontal ? (contentOffsetX + layoutMeasurementWidth)
                            : (contentOffsetY + layoutMeasurementHeight),
    ];

        // Calculate the range of visible cells.
    const cellOffsets = this.cellOffsets;
    let visibleStart = 0;

    while (cellOffsets[visibleStart++] < currentOffset[0]);
    visibleStart--;

    let visibleEnd = visibleStart;
    while (cellOffsets[visibleEnd++] <= currentOffset[1]);
    visibleEnd--;

        // Update cells' visibility
{'fraction_non_alphanumeric': 0.10579710144927536, 'fraction_numerical': 0.0016563146997929607, 'mean_word_length': 3.600952380952381, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5785752', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1325, 'n_words': 298}