<commit_before>KDView = require './../../core/view'
KDScrollThumb = require './scrollthumb.coffee'

module.exports = class KDScrollTrack extends KDView

  constructor:(options = {}, data)->

    options.type   or= 'vertical'
    options.cssClass = KD.utils.curry "kdscrolltrack #{options.type} out", options.cssClass

    super options, data

    {@type} = @getOptions()

    @thumb = new KDScrollThumb
      cssClass : 'kdscrollthumb'
      type     : @type
      track    : this


  viewAppended: ->

    super

    @addSubView @thumb


  show:->

    @getDelegate().emit 'ScrollTrackShown', @type
    @unsetClass 'invisible'


  hide:->

    @getDelegate().emit 'ScrollTrackHidden', @type
    @setClass 'invisible'

<commit_msg>CustomScrolls: implements scrolltrack click to scroll<commit_after>KDView = require './../../core/view'
KDScrollThumb = require './scrollthumb.coffee'

module.exports = class KDScrollTrack extends KDView

  constructor:(options = {}, data)->

    options.type   or= 'vertical'
    options.cssClass = KD.utils.curry "kdscrolltrack #{options.type} out", options.cssClass

    super options, data

    {@type} = @getOptions()

    @scrollView = @getDelegate()

    @thumb = new KDScrollThumb
      cssClass : 'kdscrollthumb'
      type     : @type
      track    : this


  viewAppended: ->

    super

    @addSubView @thumb


  click: (event) ->

    return  unless 'kdscrolltrack' in event.target.classList

    if @type is 'vertical'
      scrollHeight = @scrollView.getScrollHeight()
      thumbHeight  = @thumb.getHeight()
      @scrollView.scrollTo
        top : (event.offsetY - thumbHeight / 2) / @getHeight() * scrollHeight

    else
      scrollWidth = @scrollView.getScrollWidth()
      thumbWidth  = @thumb.getWidth()
      @scrollView.scrollTo
        left : (event.offsetX - thumbWidth / 2) / @getWidth() * scrollWidth


  show:->

    @getDelegate().emit 'ScrollTrackShown', @type
    @unsetClass 'invisible'


  hide:->

    @getDelegate().emit 'ScrollTrackHidden', @type
    @setClass 'invisible'


{'fraction_non_alphanumeric': 0.12622309197651663, 'fraction_numerical': 0.0009784735812133072, 'mean_word_length': 2.9026717557251906, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '924191', 'n_tokens_mistral': 667, 'n_tokens_neox': 614, 'n_words': 145}