<commit_before>// Scroll effects for the page


// Top bar text changes from white to black after scrolling a certain amount
function adjustTopBar(scroll) {
  const topBar = document.getElementsByClassName('top-bar')[0];

  // Scroll distance at which everything will switch from black to white
  const threshold = window.innerWidth > window.innerHeight
                        ? window.innerHeight * 1.25
                        : window.innerHeight * 0.95;

  // Text color changes suddenly at threshold
  if (scroll > threshold) {
    topBar.classList.add('black');
  } else {
    topBar.classList.remove('black');
  }
}


function headlineParallax(scroll) {
  requestAnimationFrame(() => {
    const headline = document.getElementsByClassName('headline')[0];
    headline.style.transform = `translateY(calc( -50% - ${scroll / 50}vh ))`;
  });
}


// Main scroll handler


function scrollHandler() {
  const scroll = window.scrollY;
  adjustTopBar(scroll);
  headlineParallax(scroll);
}

window.addEventListener('scroll', scrollHandler);<commit_msg>Automatically stop and start mist animation when it's scrolled out of / into view<commit_after>// Scroll effects for the page

// Scroll distance at which the user has scrolled into the white section
const threshold1 = window.innerWidth > window.innerHeight
                      ? window.innerHeight * 1.25
                      : window.innerHeight * 0.95;


// Top bar text changes from white to black after scrolling a certain amount
function adjustTopBar(scroll) {
  const topBar = document.getElementsByClassName('top-bar')[0];

  // Text color changes suddenly at threshold
  if (scroll > threshold1) {
    topBar.classList.add('black');
  } else {
    topBar.classList.remove('black');
  }
}


function headlineParallax(scroll) {
  requestAnimationFrame(() => {
    const headline = document.getElementsByClassName('headline')[0];
    headline.style.transform = `translateY(calc( -50% - ${scroll / 50}vh ))`;
  });
}


function adjustAnimationPlayState(scroll) {
  if (window.mistSim) {
    if (scroll > threshold1) {
      window.mistSim.stop();
    } else if (!window.mistSim.running) {
      window.mistSim.start();
    }
  }
}

// Main scroll handler


function scrollHandler() {
  const scroll = window.scrollY;
  adjustTopBar(scroll);
  headlineParallax(scroll);
  adjustAnimationPlayState(scroll);
}

window.addEventListener('scroll', scrollHandler);
{'fraction_non_alphanumeric': 0.11419114604882086, 'fraction_numerical': 0.011170872983036822, 'mean_word_length': 3.4612546125461257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '7210854', 'n_tokens_mistral': 714, 'n_tokens_neox': 671, 'n_words': 181}