mqfunctions
v0.2.1
Published
JavaScript library to manage matchMedia handlers.
Downloads
4
Readme
mqfunctions
JavaScript library to manage matchMedia handlers.
Install
npm install mqfunctions
Use
import { createMqFunctions } from 'mqfunctions'
const mqf = createMqFunctions('(min-width: 768px)')
// Add matchMedia handler
mqf.add('function-01', (event) => {
if (event.matches) {
console.log('Resized window to PC size!')
} else {
console.log('Resized window to SP size!')
}
})
// Run handler arbitrarily
mqf.run('function-01')
// Remove handler
mqf.remove('function-01')