# mediaquery-js

> ES6 CSS3 mediaquery to JavaScript bridge

Latest version **1.0.2** (published 2016-02-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install mediaquery-js
pnpm add mediaquery-js
yarn add mediaquery-js
bun add mediaquery-js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2016-02-11 |
| First published | 2015-05-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Edo Balvers |
| Maintainers | ehtb |
| Keywords | mq |

## Links

- npm: https://www.npmjs.com/package/mediaquery-js
- Repository: https://github.com/ehtb/mediaquery-js
- Homepage: https://github.com/ehtb/mediaquery-js#readme
- Issues: https://github.com/ehtb/mediaquery-js/issues
- npm.io page: https://npm.io/package/mediaquery-js

## Dependencies (1)

- [throttled-resize](https://npm.io/package/throttled-resize.md) ^1.0.1

## Recent versions

- 1.0.2 (latest) — 2016-02-11
- 0.2.1 — 2015-05-29
- 0.2.0 — 2015-05-29
- 0.1.4 — 2015-05-29
- 0.1.3 — 2015-05-29
- 0.1.2 — 2015-05-28
- 0.1.1 — 2015-05-28
- 0.1.0 — 2015-05-27

## README

# Mediaquery -js

ES6 CSS3 mediaquery to JavaScript bridge using the ```content``` psuedo element

## JS


```js
import MQ from 'mediaquery-js';

let mq = new MQ(computationalElement);

// Mediaquery change event
mq.on('mq:change', fn);

// Get the current Mediaquery
mq.breakpoint;

```

## CSS

You can set computationalElement to any element in the DOM.
If you don't pass an argument, it will fall back to the ```<html>``` element.

Next you add some CSS to the element you want to test your mediaquery to.
It uses the content attribute to identify the breakpoint.

```css
html:after {
  clip: rect(0 0 0 0);
  height: 0;
  left: -9999px;
  overflow: hidden;
  position: absolute;
  top: -9999px;
  visibility: hidden;
  width: 0;
}

@media (max-width: 600px) {
  html:after {
    content: 'sm';
  }
}

@media (min-width: 601px) {
  html:after {
    content: 'lg';
  }
}
```

## Browser Support

[![Browser Support](http://ci.testling.com/ehtb/resize.png)](http://ci.testling.com/ehtb/resize)

---
_Source: https://npm.io/package/mediaquery-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
