{"id":25031868,"url":"https://github.com/lgraubner/mqr","last_synced_at":"2025-03-30T19:40:29.646Z","repository":{"id":57153546,"uuid":"90372799","full_name":"lgraubner/mqr","owner":"lgraubner","description":"Functional matchMedia wrapper for media query handling.","archived":false,"fork":false,"pushed_at":"2017-07-28T12:27:35.000Z","size":76,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T16:53:20.038Z","etag":null,"topics":["breakpoint","functional","matchmedia","mediaqueries","mediaquery","responsive","state"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lgraubner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-05T12:20:54.000Z","updated_at":"2019-12-09T04:07:31.000Z","dependencies_parsed_at":"2022-09-06T21:41:13.559Z","dependency_job_id":null,"html_url":"https://github.com/lgraubner/mqr","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgraubner%2Fmqr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgraubner%2Fmqr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgraubner%2Fmqr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgraubner%2Fmqr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lgraubner","download_url":"https://codeload.github.com/lgraubner/mqr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246372505,"owners_count":20766625,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["breakpoint","functional","matchmedia","mediaqueries","mediaquery","responsive","state"],"created_at":"2025-02-05T22:45:24.493Z","updated_at":"2025-03-30T19:40:29.616Z","avatar_url":"https://github.com/lgraubner.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mqr\n\n[![npm](https://img.shields.io/npm/v/mqr.svg)](https://www.npmjs.com/package/mqr) [![Travis](https://img.shields.io/travis/lgraubner/mqr.svg)](https://travis-ci.org/lgraubner/mqr) [![David](https://img.shields.io/david/lgraubner/mqr.svg)](https://david-dm.org/lgraubner/mqr)\n\n\u003e Functional matchMedia wrapper for media query handling.\n\nSmall functional wrapper for `matchMedia` to work with media queries in JavaScript. Weighs only 359b, has no dependencies and supports IE10+. To support legacy browsers a [polyfill](https://github.com/paulirish/matchMedia.js) is required.\n\n## Table of contents\n\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n- [License](#license)\n\n## Install\n\nThis module is available on [npm](https://www.npmjs.com/).\n\n```\n$ npm install mqr\n```\n\nIf you are using some kind of bundler ([webpack](https://webpack.js.org), [rollup](https://rollupjs.org)...) you can import it like this:\n\n```JavaScript\n// ES6\nimport mqr from 'mqr';\n\n// CommonJS\nvar mqr = require('mqr');\n```\n\nThe [UMD](https://github.com/umdjs/umd) build is also available on [unpkg](https://unpkg.com/#/):\n\n```HTML\n\u003cscript src=\"https://unpkg.com/mqr/dist/mqr.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\n```JavaScript\nimport mqr from 'mqr';\n\nconst query = mqr();\n\n// listen to viewport changes\nquery.listen('(min-width: 768px)', matches =\u003e {\n  console.log(matches); // boolean\n});\n\n// listen + remove handler\nfunction handler() {}\nquery.listen('(min-width: 768px)', handler);\nquery.remove('(min-width: 768px)', handler);\n\n// simple media query check\nconst matches = query.matches('(min-width: 992px)');\nconsole.log(matches); // boolean\n```\n\n## API\n\n### mqr()\n\nInitializes mqr, returns instance with methods.\n\n```JavaScript\nconst query = mqr();\n```\n\n### mqr.listen(query, handler[, execute])\n\nRegister a handler for a given media query. Handler will be executed once every time the breakpoint is reached. If `execute` is `true` (default) the handler will also be called when it's registered.\n\n```JavaScript\nquery.listen('(min-width: 768px)', matches =\u003e {\n  console.log(matches); // boolean\n}, false);\n```\n\n### mqr.remove(query, handler)\n\nRemoves a previously registered media query handler.\n\n```JavaScript\nfunction handler() {}\nquery.listen('(min-width: 768px)', handler);\nquery.remove('(min-width: 768px)', handler);\n```\n\n### mqr.matches(query)\n\nChecks if given media query is matching.\n\n```JavaScript\nconst matches = query.matches('(min-width: 992px)');\nconsole.log(matches); // boolean\n```\n\n## License\n\n[MIT](https://github.com/lgraubner/mqr/blob/master/LICENSE) © [Lars Graubner](https://larsgraubner.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flgraubner%2Fmqr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flgraubner%2Fmqr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flgraubner%2Fmqr/lists"}