main

animate-css/animate.css

Last updated at: 28/12/2023 01:32

slowDownAnimations.mjs

TLDR

This file exports a function called slowDownAnimations that slows down animations when a specific target element is clicked.

Methods

None

Classes

None

/**
  Slows animations
*/

const slowDownAnimations = (target) => {
  const targetEl = document.querySelector(target)
  const doc = document.documentElement

  targetEl.addEventListener('click', () => {
    const currentDuration = getComputedStyle(document.documentElement)
      .getPropertyValue('--animate-duration')
    const newDuration = currentDuration === '1s' ? '2s' : '1s'

    document.documentElement.style.setProperty('--animate-duration', newDuration);
  })
}

export default slowDownAnimations