<commit_before>const React = require('react');
const ReactDOM = require('react-dom');
const ScrollWatch = require('scrollwatch');

//http://stackoverflow.com/questions/4588119/get-elements-css-selector-when-it-doesnt-have-an-id
function fullPath(el){
  var names = [];
  while (el.parentNode){
    if (el.id){
      names.unshift('#'+el.id);
      break;
    }else{
      if (el==el.ownerDocument.documentElement) names.unshift(el.tagName);
      else{
        for (var c=1,e=el;e.previousElementSibling;e=e.previousElementSibling,c++);
        names.unshift(el.tagName+":nth-child("+c+")");
      }
      el=el.parentNode;
    }
  }
  return names.join(" > ");
}

class IdyllComponent extends React.PureComponent {
  constructor(props) {
    super(props);

    if (props.onEnteredView) {
      this.componentDidMount = () => {
        const dom = ReactDOM.findDOMNode(this);
        var sw = new ScrollWatch({
          watch: fullPath(dom),
          onElementInView: this.props.onEnteredView,
          watchOnce: false
        });<commit_msg>add onExitView<commit_after>const React = require('react');
const ReactDOM = require('react-dom');
const ScrollWatch = require('scrollwatch');

//http://stackoverflow.com/questions/4588119/get-elements-css-selector-when-it-doesnt-have-an-id
function fullPath(el){
  var names = [];
  while (el.parentNode){
    if (el.id){
      names.unshift('#'+el.id);
      break;
    }else{
      if (el==el.ownerDocument.documentElement) names.unshift(el.tagName);
      else{
        for (var c=1,e=el;e.previousElementSibling;e=e.previousElementSibling,c++);
        names.unshift(el.tagName+":nth-child("+c+")");
      }
      el=el.parentNode;
    }
  }
  return names.join(" > ");
}

class IdyllComponent extends React.PureComponent {
  constructor(props) {
    super(props);

    if (props.onEnteredView || props.onExitView) {
      this.componentDidMount = () => {
        const dom = ReactDOM.findDOMNode(this);
        var sw = new ScrollWatch({
          watch: fullPath(dom),
          onElementInView: props.onEnteredView,
          onElementOutOfView: props.onExitView,
          watchOnce: false
        });
{'fraction_non_alphanumeric': 0.1525974025974026, 'fraction_numerical': 0.0074211502782931356, 'mean_word_length': 3.0469043151969983, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, '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': '840241', 'n_tokens_mistral': 718, 'n_tokens_neox': 707, 'n_words': 112}