<commit_before>import { getThrottleLazyload } from '../utils'

export default {
  methods: {
    updateLayout () {
      const wrapper = this.$refs.wrapper
      if (wrapper) {
        const rect = wrapper.getBoundingClientRect()
        this.wrapperWidth = rect.width
        this.wrapperHeight = rect.height
      }
    },

    handleScroll (event) {
      getThrottleLazyload(25, this.$el, 'scroll')()
      if (this.reachBottom()) {
        this.$emit('loadmore', event)
      }
    },

    reachTop () {
      const wrapper = this.$refs.wrapper
      return (!!wrapper) && (wrapper.scrollTop <= 0)
    },

    reachBottom () {
      const wrapper = this.$refs.wrapper
      const inner = this.$refs.inner
      const offset = Number(this.loadmoreoffset) || 0

      if (wrapper && inner) {
        const innerHeight = inner.getBoundingClientRect().height<commit_msg>* [html5] support scroll event & offset-accuracy attribute.<commit_after>import { getThrottleLazyload, throttle } from '../utils'

let throttleScroll
function getThrottledScroll (context) {
  if (!throttleScroll) {
    const wrapper = context.$refs.wrapper
    const inner = context.$refs.inner
    let preOffset = (context.scrollDirection === 'horizontal'
        ? wrapper.scrollLeft
        : wrapper.scrollTop)
      || 0
    throttleScroll = throttle(function (evt) {
      const offset = context.scrollDirection === 'horizontal'
        ? wrapper.scrollLeft
        : wrapper.scrollTop
      const indent = parseInt(context.offsetAccuracy)
      function triggerScroll () {
        const rect = inner.getBoundingClientRect()
        evt.contentSize = { width: rect.width, height: rect.height }
        evt.contentOffset = {
          x: wrapper.scrollLeft,
          y: wrapper.scrollTop
        }
        context.$emit('scroll', evt)
      }
      if (indent
        && !isNaN(indent)
        && indent > 0
        && Math.abs(offset - preOffset) >= indent) {
        triggerScroll()
        preOffset = offset
      }
      else if (!indent || isNaN(indent) || indent <= 0) {
        triggerScroll()
      }
    }, 16, true)
  }
  return throttleScroll
}

export default {
  props: {
    offsetAccuracy: [Number, String]
  },
  methods: {
    updateLayout () {
      const wrapper = this.$refs.wrapper
      if (wrapper) {
        const rect = wrapper.getBoundingClientRect()
        this.wrapperWidth = rect.width
        this.wrapperHeight = rect.height
      }
    },

    handleScroll (event) {
      getThrottleLazyload(25, this.$el, 'scroll')()
      getThrottledScroll(this)(event)
      if (this.reachBottom()) {
        this.$emit('loadmore', event)
      }
    },

    reachTop () {
      const wrapper = this.$refs.wrapper
      return (!!wrapper) && (wrapper.scrollTop <= 0)
    },

    reachBottom () {
      const wrapper = this.$refs.wrapper
      const inner = this.$refs.inner
      const offset = Number(this.loadmoreoffset) || 0

      if (wrapper && inner) {
        const innerHeight = inner.getBoundingClientRect().height
{'fraction_non_alphanumeric': 0.12243547319655856, 'fraction_numerical': 0.004632693580410324, 'mean_word_length': 2.366369710467706, 'pattern_counts': {'":': 0, '<': 6, '<?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': '3295844', 'n_tokens_mistral': 892, 'n_tokens_neox': 867, 'n_words': 190}