media-trigger
v3.1.1
Published
MediaTrigger is designed to control the response to changes in media queries, allowing you to perform specific actions when entering or exiting a particular media state, or any change to a media state.
Downloads
26
Maintainers
Readme
350B gzipped
Demo
➤ Install
$ yarn add media-trigger
➤ Import
import MediaTrigger from 'media-trigger';
➤ Usage
const mediaTrigger = new MediaTrigger({
media: '(min-width: 992px)',
entry: (mq) => {
console.log('Entered media query:', mq.media);
},
exit: (mq) => {
console.log('Exited media query:', mq.media);
},
change: (mq) => {
console.log('Media query change:', mq.media, 'matches:', mq.matches);
}
});
mediaTrigger.init();
➤ License
media-trigger is released under MIT license