Okazari/Rythm.js

View on GitHub
src/dances/blur.js

Summary

Maintainability
B
5 hrs
Test Coverage
export default (elem, value, options = {}) => {
  const max = !isNaN(options.max) ? options.max : 8
  const min = !isNaN(options.min) ? options.min : 0
  let blur = (max - min) * value
  if (options.reverse) {
    blur = max - blur
  } else {
    blur = min + blur
  }
  elem.style.filter = `blur(${blur}px)`
}

export const reset = elem => {
  elem.style.filter = ''
}