<commit_before>class Corporate.Header
  constructor: ->
    @window = $(window)
    @autoScrolling = false
    @sections = []
    @triggerBlueBgOffset = 40
    @headerHeight = $('#header').outerHeight()

    @getSectionsData()
    @bindEvents()

  bindEvents: ->
    @window.scroll @scroll
    @window.resize @getSectionsData
    $('.scroll-to').click @scrollTo

  reachedTop: (section, sectionData) ->
    scrollTopWithHeader = @scrollTop + @headerHeight
    scrollTopWithHeader >= sectionData.offsetTop && scrollTopWithHeader <= sectionData.height + sectionData.offsetTop

  reachedBottom: ->
    @scrollTop >= @maxScroll()

  maxScroll: ->
    $(document).height() - @window.height()

  getSectionsData: =>
    $('section, #footer').each (index, section) =>
      $section = $(section)
      @sections[$section.attr('id')] = 
        offsetTop: $section.offset().top
        height: $section.outerHeight()

  updateNavigation: =>
    for section, sectionData of @sections
      if (@reachedTop(section, sectionData) || @reachedBottom())
        current = if @reachedBottom() then 'footer' else section
        $('.header__navigation-item a').removeClass('active')
        $('.header__navigation-item a[href=#' + current + ']').addClass('active')

  scroll: =>
    @scrollTop = @window.scrollTop()
    $body = $('body')
    scale = Math.max(1, 1 + (@scrollTop / 6000))

    if @scrollTop >= @triggerBlueBgOffset then $body.addClass('scrolled') else $body.removeClass('scrolled')
    $('.parallax-bg').css('transform', 'scale(' + scale + ')') if @scrollTop <= $('#intro').outerHeight()
    @updateNavigation() unless @autoScrolling

  scrollTo: (e) =><commit_msg>Refactor some functions<commit_after>class Corporate.Header
  constructor: ->
    @window = $(window)
    @autoScrolling = false
    @sections = []
    @triggerBlueBgOffset = 40
    @headerHeight = $('#header').outerHeight()

    @getSectionsData()
    @bindEvents()

  bindEvents: ->
    @window.scroll @scroll
    @window.resize @getSectionsData
    $('.scroll-to').click @scrollTo

  sectionReachedTop: (section, sectionData) ->
    scrollTopWithHeader = @scrollTop + @headerHeight
    scrollTopWithHeader >= sectionData.offsetTop && scrollTopWithHeader <= sectionData.height + sectionData.offsetTop

  scrollReachedBottom: ->
    @scrollTop >= @maxScroll()

  maxScroll: ->
    $(document).height() - @window.height()

  getSectionsData: =>
    $('section, #footer').each (index, section) =>
      $section = $(section)
      @sections[$section.attr('id')] = 
        offsetTop: $section.offset().top
        height: $section.outerHeight()

  updateNavigation: =>
    for section, sectionData of @sections
      if (@sectionReachedTop(section, sectionData) || @scrollReachedBottom())
        current = if @scrollReachedBottom() then 'footer' else section
        $('.header__navigation-item a').removeClass('active')
        $('.header__navigation-item a[href=#' + current + ']').addClass('active')

  scroll: =>
    @scrollTop = @window.scrollTop()
    $body = $('body')
    scale = Math.max(1, 1 + (@scrollTop / 6000))

    if @scrollTop >= @triggerBlueBgOffset then $body.addClass('scrolled') else $body.removeClass('scrolled')
    $('.parallax-bg').css('transform', 'scale(' + scale + ')') if @scrollTop <= $('#intro').outerHeight()
    @updateNavigation() unless @autoScrolling

  scrollTo: (e) =>
{'fraction_non_alphanumeric': 0.16498516320474776, 'fraction_numerical': 0.004747774480712166, 'mean_word_length': 3.7545839210155147, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 29, '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': '2390161', 'n_tokens_mistral': 1025, 'n_tokens_neox': 984, 'n_words': 204}