1.4.3 • Published 2 years ago

@iamkhan21/media-query-js v1.4.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@iamkhan21/media-query-js

Use like css media queries in code instead ResizeObserver

npm version npm downloads

Install

npm i @iamkhan21/media-query-js

Usage

import { MediaQuery } from "@iamkhan21/media-query-js";

const query = "(max-width: 768px)";
function onChange(matches: boolean) {
  console.log(`Screen width is ${matches ? "less" : "more"} than 768px`);
}

// You will recieve match result after class initialization
const mq = new MediaQuery(query, onChange);
// For screen width more than 768px
// console.log("Screen width is more than 768px")

// Also you can subscribe and track width changes
mq.on();

// To unsubscribe call next:
mq.off();
1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.1.0

3 years ago

1.0.2

3 years ago