<commit_before>( function ( document, window )
{
  'use strict';

  var elSelector = 'header',
    element	= document.querySelector( elSelector );

  if( !element ) return true;

  var elHeight = 0,
    elTop	= 0,
    dHeight	= 0,
    wHeight	= 0,
    wScrollCurrent = 0,
    wScrollBefore	= 0,
    wScrollDiff	= 0;

  window.addEventListener( 'scroll', function()
  {
    elHeight = element.offsetHeight;
    dHeight = document.body.offsetHeight;
    wHeight = window.innerHeight;
    wScrollCurrent = window.pageYOffset;
    wScrollDiff = wScrollBefore - wScrollCurrent;
    elTop = parseInt( window.getComputedStyle( element ).getPropertyValue( 'top' ) ) + wScrollDiff;

    if( wScrollCurrent <= 0 ) {
      element.style.top = '0px'
    } else if( wScrollDiff > 0 ) {
      element.style.top = ( elTop > 0 ? 0 : elTop ) + 'px'
    } else if( wScrollDiff < 0 ) {
      if( wScrollCurrent + wHeight >= dHeight - elHeight ) {
        element.style.top = ( ( elTop = wScrollCurrent + wHeight - dHeight ) < 0 ? elTop : 0 ) + 'px'
      } else {
        element.style.top = ( Math.abs( elTop ) > elHeight ? -elHeight : elTop ) + 'px'
      }
    }

    wScrollBefore = wScrollCurrent;
  });

}( document, window, 0 ));


<commit_msg>code cleanup<commit_after>( function ( document, window )
{
  'use strict';

  var elSelector = 'header',
    element	= document.querySelector( elSelector );

  if( !element ) return true;

  var elHeight = 0,
    elTop = 0,
    dHeight = 0,
    wHeight = 0,
    wScrollCurrent = 0,
    wScrollBefore = 0,
    wScrollDiff = 0;

  window.addEventListener( 'scroll', function()
  {
    elHeight = element.offsetHeight;
    dHeight = document.body.offsetHeight;
    wHeight = window.innerHeight;
    wScrollCurrent = window.pageYOffset;
    wScrollDiff = wScrollBefore - wScrollCurrent;
    elTop = parseInt( window.getComputedStyle( element ).getPropertyValue( 'top' ) ) + wScrollDiff;

    if( wScrollCurrent <= 0 ) {
      element.style.top = '0px'
    } else if( wScrollDiff > 0 ) {
      element.style.top = ( elTop > 0 ? 0 : elTop ) + 'px'
    } else if( wScrollDiff < 0 ) {
      if( wScrollCurrent + wHeight >= dHeight - elHeight ) {
        element.style.top = ( ( elTop = wScrollCurrent + wHeight - dHeight ) < 0 ? elTop : 0 ) + 'px'
      } else {
        element.style.top = ( Math.abs( elTop ) > elHeight ? -elHeight : elTop ) + 'px'
      }
    }

    wScrollBefore = wScrollCurrent;
  });

}( document, window, 0 ));



{'fraction_non_alphanumeric': 0.12992285830288267, 'fraction_numerical': 0.012992285830288266, 'mean_word_length': 2.634218289085546, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '6611062', 'n_tokens_mistral': 849, 'n_tokens_neox': 809, 'n_words': 197}