rixutils
v1.0.2
Published
Collection of nice to have browser functions that I needed multiple times.
Downloads
1
Readme
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')
}