<commit_before>import React, { Component, PropTypes } from 'react'

import ReactLoryList from './react-lory-list'

const EVENTS = {
  AFTER_DESTROY: 'after.lory.destroy',
  AFTER_INIT: 'after.lory.init',
  AFTER_SLIDE: 'after.lory.slide',
  BEFORE_SLIDE: 'before.lory.slide',
  RESIZE: 'on.lory.resize'
}

const NO_OP = () => {}

// in order to make react-lory compatible with server-rendering
// by default lory and imagesLoaded are empty functions
let lory = NO_OP
let imagesLoaded = NO_OP

// if window is present, then we get the needed library
if (typeof (window) !== 'undefined' && window.document) {
  lory = require('lory.js').lory
  imagesLoaded = require('imagesloaded')
}

export default class ReactLorySlider extends Component {

  constructor (...args) {
    super(...args)
    this.getSliderNode = this.getSliderNode.bind(this)
    this.handleBeforeSlide = this.handleBeforeSlide.bind(this)
    this.handleAfterInit = this.handleAfterInit.bind(this)
    this.handleAfterSlide = this.handleAfterSlide.bind(this)
    this.handleDestroy = this.handleDestroy.bind(this)
    this.handleResize = this.handleResize.bind(this)
    this.loryInstance = null

    this.state = { currentSlide: 0 }
    this.sliderOptions = {
      classNameItem: this.getClassName('item'),
      classNameFrame: this.getClassName('frame'),
      classNameSlideContainer: this.getClassName('slides'),
      classNamePrevCtrl: this.getClassName('prev'),
      classNameNextCtrl: this.getClassName('next'),
      // fix if the user try to use a `true` value for infinite
      infinite: this.props.infinite === true ? 1 : this.props.infinite,
      // if infinite, rewindOnResize is always true
      rewindOnResize: this.props.rewindOnResize || this.props.infinite
    }
  }

  componentDidMount () {
    // wait to load the images in order to start some stuff only when needed
    const imgLoad = imagesLoaded(this.sliderNode)
    imgLoad.once('done', () => {
      this.sliderNode.addEventListener(EVENTS.AFTER_DESTROY, this.handleDestroy)
      this.sliderNode.addEventListener(EVENTS.AFTER_SLIDE, this.handleAfterSlide)
      this.sliderNode.addEventListener(EVENTS.INIT, this.handleAfterInit)
      this.sliderNode.addEventListener(EVENTS.BEFORE_SLIDE, this.handleBeforeSlide)
      this.sliderNode.addEventListener(EVENTS.RESIZE, this.handleResize)
      // start lory slider instance
      this.loryInstance = lory(this.sliderNode, {...this.props, ...this.sliderOptions})
    })
  }

  componentWillUnmount () {
    this.sliderNode.removeEventListener(EVENTS.INIT, this.handleAfterInit)
    this.sliderNode.removeEventListener(EVENTS.AFTER_SLIDE, this.handleAfterSlide)
    this.sliderNode.removeEventListener(EVENTS.BEFORE_SLIDE, this.handleBeforeSlide)
    this.sliderNode.removeEventListener(EVENTS.RESIZE, this.handleResize)
    this.loryInstance.destroy()
    this.sliderNode.removeEventListener(EVENTS.AFTER_DESTROY, this.handleDestroy)
  }

  shouldComponentUpdate (nextProps, nextState) {
    return nextState.currentSlide !== this.state.currentSlide
  }

  getClassName (element) {
    return `${this.props.classNameBase}-${element}`<commit_msg>Fix event name<commit_after>import React, { Component, PropTypes } from 'react'

import ReactLoryList from './react-lory-list'

const EVENTS = {
  AFTER_DESTROY: 'after.lory.destroy',
  AFTER_INIT: 'after.lory.init',
  AFTER_SLIDE: 'after.lory.slide',
  BEFORE_SLIDE: 'before.lory.slide',
  RESIZE: 'on.lory.resize'
}

const NO_OP = () => {}

// in order to make react-lory compatible with server-rendering
// by default lory and imagesLoaded are empty functions
let lory = NO_OP
let imagesLoaded = NO_OP

// if window is present, then we get the needed library
if (typeof (window) !== 'undefined' && window.document) {
  lory = require('lory.js').lory
  imagesLoaded = require('imagesloaded')
}

export default class ReactLorySlider extends Component {

  constructor (...args) {
    super(...args)
    this.getSliderNode = this.getSliderNode.bind(this)
    this.handleBeforeSlide = this.handleBeforeSlide.bind(this)
    this.handleAfterInit = this.handleAfterInit.bind(this)
    this.handleAfterSlide = this.handleAfterSlide.bind(this)
    this.handleDestroy = this.handleDestroy.bind(this)
    this.handleResize = this.handleResize.bind(this)
    this.loryInstance = null

    this.state = { currentSlide: 0 }
    this.sliderOptions = {
      classNameItem: this.getClassName('item'),
      classNameFrame: this.getClassName('frame'),
      classNameSlideContainer: this.getClassName('slides'),
      classNamePrevCtrl: this.getClassName('prev'),
      classNameNextCtrl: this.getClassName('next'),
      // fix if the user try to use a `true` value for infinite
      infinite: this.props.infinite === true ? 1 : this.props.infinite,
      // if infinite, rewindOnResize is always true
      rewindOnResize: this.props.rewindOnResize || this.props.infinite
    }
  }

  componentDidMount () {
    // wait to load the images in order to start some stuff only when needed
    const imgLoad = imagesLoaded(this.sliderNode)
    imgLoad.once('done', () => {
      this.sliderNode.addEventListener(EVENTS.AFTER_DESTROY, this.handleDestroy)
      this.sliderNode.addEventListener(EVENTS.AFTER_SLIDE, this.handleAfterSlide)
      this.sliderNode.addEventListener(EVENTS.AFTER_INIT, this.handleAfterInit)
      this.sliderNode.addEventListener(EVENTS.BEFORE_SLIDE, this.handleBeforeSlide)
      this.sliderNode.addEventListener(EVENTS.RESIZE, this.handleResize)
      // start lory slider instance
      this.loryInstance = lory(this.sliderNode, {...this.props, ...this.sliderOptions})
    })
  }

  componentWillUnmount () {
    this.sliderNode.removeEventListener(EVENTS.AFTER_INIT, this.handleAfterInit)
    this.sliderNode.removeEventListener(EVENTS.AFTER_SLIDE, this.handleAfterSlide)
    this.sliderNode.removeEventListener(EVENTS.BEFORE_SLIDE, this.handleBeforeSlide)
    this.sliderNode.removeEventListener(EVENTS.RESIZE, this.handleResize)
    this.loryInstance.destroy()
    this.sliderNode.removeEventListener(EVENTS.AFTER_DESTROY, this.handleDestroy)
  }

  shouldComponentUpdate (nextProps, nextState) {
    return nextState.currentSlide !== this.state.currentSlide
  }

  getClassName (element) {
    return `${this.props.classNameBase}-${element}`
{'fraction_non_alphanumeric': 0.11268052690049199, 'fraction_numerical': 0.0006348198698619266, 'mean_word_length': 4.144489795918368, 'pattern_counts': {'":': 0, '<': 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': '6169212', 'n_tokens_mistral': 1925, 'n_tokens_neox': 1926, 'n_words': 375}