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

export default class Scroll extends Component {
  constructor(props) {
    super(props)
    this.state = {
      couldScroll: false,
      maxBarScroll: 0,
      maxPageScroll: 0,
      barOpacity: 0
    }
    this.initScrollerBar = this.initScrollerBar.bind(this)
  } 

  componentDidMount() {
    this.initScrollerWidth()
    this.initScrollerBar()
    if (window.addEventListener) { 
      window.addEventListener('resize', this.initScrollerBar, false)
    }
  }

  initScrollerWidth() {
    const { container, scroller } = this.refs
    scroller.style.width = container.offsetWidth + 'px'
  }

  initScrollerBar() {
    const { container, scroller, scrollbar } = this.refs

    const conHeight = container.offsetHeight
    const scrHeight = scroller.offsetHeight
    const ratio = conHeight / scrHeight
    const barHeight = conHeight * ratio

    if (ratio >= 1) {
      this.setState({
        couldScroll: false
      })
      scrollbar.style.display = 'none'
    } else {
      this.setState({
        couldScroll: true,
        maxBarScroll: conHeight - barHeight,
        maxPageScroll: scrHeight - conHeight
      })
      scrollbar.style.display = 'block'
      scrollbar.style.height = barHeight + 'px'
    }
  }

  onScrollHandle() {
    if (!this.state.couldScroll)
      return
    const { wrapper, scrollbar } = this.refs
    const { maxBarScroll, maxPageScroll } = this.state
    scrollbar.style.top = ~~(wrapper.scrollTop * maxBarScroll / maxPageScroll) + 'px'
  }

  render () {
    const { children, bgColor, barStyles } = this.props
<commit_msg>fix some details<commit_after>import React, { Component } from 'react'

export default class Scroll extends Component {
  constructor(props) {
    super(props)
    this.state = {
      couldScroll: false,
      maxBarScroll: 0,
      maxPageScroll: 0,
      barOpacity: 0
    }
    this.initScrollerBar = this.initScrollerBar.bind(this)
  } 

  componentDidMount() {
    this.initScrollerWidth()
    this.initScrollerBar()
    if (window.addEventListener) { 
      window.addEventListener('resize', this.initScrollerBar, false)
    }
  }

  initScrollerWidth() {
    const { container, scroller } = this.refs
    scroller.style.width = container.offsetWidth + 'px'
  }

  initScrollerBar() {
    const { container, scroller, scrollbar } = this.refs

    const conHeight = container.offsetHeight
    const scrHeight = scroller.offsetHeight
    const ratio = conHeight / scrHeight
    let barHeight = conHeight * ratio
    barHeight < 50 ? barHeight = 50 : null

    if (ratio >= 1) {
      this.setState({
        couldScroll: false
      })
      scrollbar.style.display = 'none'
    } else {
      this.setState({
        couldScroll: true,
        maxBarScroll: conHeight - barHeight,
        maxPageScroll: scrHeight - conHeight
      })
      scrollbar.style.display = 'block'
      scrollbar.style.height = barHeight + 'px'
    }
  }

  onScrollHandle() {
    if (!this.state.couldScroll)
      return
    const { wrapper, scrollbar } = this.refs
    const { maxBarScroll, maxPageScroll } = this.state
    scrollbar.style.top = ~~(wrapper.scrollTop * maxBarScroll / maxPageScroll) + 'px'
  }

  render () {
    const { children, bgColor, barStyles } = this.props

{'fraction_non_alphanumeric': 0.10571081409477522, 'fraction_numerical': 0.0036452004860267314, 'mean_word_length': 2.7, 'pattern_counts': {'":': 0, '<': 4, '<?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': '6056403', 'n_tokens_mistral': 1018, 'n_tokens_neox': 987, 'n_words': 219}