Skip to content

Collection of nice to have browser functions that I needed multiple times.

License

Notifications You must be signed in to change notification settings

rybarix/rixutils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RIXUTILS

  • monitor.js

    • Easy to use wrapper around IntersectionObserver browser API
    • Good for adding animation when elements appear on the screen
  • prefmotion.js

    • Good for determining whether to run motion intensive scripts.

Usage

monitor

const observe = monitor({ threshold: 0.2, trigger: 'once' })

observe(document.querySelector('#elementToObserve'), () => {
  // what to do when this element appears on the screen?
})

prefsmotion

prefersMotion(() => {
    console.log('im ok with motion')
  }, () => {
    console.log('im not ok with motion')
})

// 
if (isMotionPreferred()) {
  console.log('motion is OK')
} else {
  console.log('motion is NOT OK')
}

About

Collection of nice to have browser functions that I needed multiple times.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published