mqfunctions
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

mqfunctions

Test Status License MIT npm version codecov

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')

License

MIT License.

Package Sidebar

Install

npm i mqfunctions

Weekly Downloads

30

Version

0.2.1

License

MIT

Unpacked Size

40.5 kB

Total Files

15

Last publish

Collaborators

  • kimulaco