{"id":13536164,"url":"https://github.com/AStaroverov/v-media-query","last_synced_at":"2025-04-02T02:32:32.579Z","repository":{"id":4122115,"uuid":"52066607","full_name":"AStaroverov/v-media-query","owner":"AStaroverov","description":"easy media query for vue","archived":false,"fork":false,"pushed_at":"2022-12-10T01:30:48.000Z","size":425,"stargazers_count":104,"open_issues_count":13,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-19T09:09:45.459Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AStaroverov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-19T06:28:26.000Z","updated_at":"2024-02-14T20:21:46.000Z","dependencies_parsed_at":"2023-01-11T20:12:15.972Z","dependency_job_id":null,"html_url":"https://github.com/AStaroverov/v-media-query","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AStaroverov%2Fv-media-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AStaroverov%2Fv-media-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AStaroverov%2Fv-media-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AStaroverov%2Fv-media-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AStaroverov","download_url":"https://codeload.github.com/AStaroverov/v-media-query/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222795273,"owners_count":17038797,"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":[],"created_at":"2024-08-01T09:00:35.363Z","updated_at":"2024-11-03T01:30:31.172Z","avatar_url":"https://github.com/AStaroverov.png","language":"JavaScript","funding_links":[],"categories":["实用库","Awesome Vue.js [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)","Awesome Vue.js"],"sub_categories":["Libraries \u0026 Plugins"],"readme":"# vue media query methods ([ru](https://github.com/AStaroverov/v-media-query/blob/master/README_RU.md))\nPlugin adds methods for work with media query in vue\n\n## General example:\n```javascript\nimport vMediaQuery from 'v-media-query'\n\nVue.use(vMediaQuery.default)\n```\n\n```html\n\u003csome-component v-if=\"$mq.resize \u0026\u0026 $mq.above('600px')\"\u003e\u003c/some-component\u003e\n```\nv-if gets ``true`` for screen with ``width \u003e 600px`` and updates after resizing\n\n```javascript\nnew Vue({\n  created() {\n    if (this.$mq.above(600)) {\n      console.log('screen \u003e 600px')\n    }\n  }\n})\n\nnew Vue({\n  watch: {\n    '$mq.resize': 'screenResize'\n  },\n  methods: {\n    screenResize() {\n      if (this.$mq.above(600)) {\n        console.log('screen \u003e 600px')\n      }\n    }\n  }\n})\n\nnew Vue({\n  computed: {\n    screenMore600() {\n      return this.$mq.resize \u0026\u0026 this.$mq.above(600)\n    }\n  }\n})\n```\nand [here](http://rawcdn.githack.com/AStaroverov/v-media-query/f35354a69a6e9dc05a1dd37237c597505b790f32/index.html)\n\n## Defaults methods\nAll methods are allowed in ``$mq`` (mq = media query)\n\n``$mq.resize``\n  * variable is trigger that update methods\n\n---\n\n``$mq.above(measurement, value)`` \u003cbr/\u003e\n``$mq.below(measurement, value)`` \u003cbr/\u003e\n``$mq.between(measurement, [valMin, valMax])`` \u003cbr/\u003e\n``$mq.beyond(measurement, [valMin, valMAx])`` \u003cbr/\u003e\n\n  * ``measurement``\n    * Can take values: ``'width'``, ``'height'``\n    * Default value = ``'width'`` \u003cbr/\u003e\n      example: ``$mq.above(600) == $mq.above('width', 600)``\n  * ``value, valMin, valMax``\n    * Can take type ``Number`` and ``String``\n    * All values type of ``Number`` will be rewrited to ``Number + 'px'`` \u003cbr/\u003e\n      example: ``$mq.above(600) == $mq.above('600px')``\n\n---\n\n``$mq.expr(expression)``\n  * expression - any valid css media query \u003cbr/\u003e\n    example: $mq.expr('screen and (max-device-width: 300px)')\n\n## Custom methods\nYour can add custom methods to default methods\n\n### Example\n```javascript\nVue.use(vMediaQuery.default, {\n  methods: {\n    onlyForRetina() {\n      return matchMedia('(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)').matches\n    }\n    fackAbove(...args) {\n      return vMediaQuery.methods.above(...args)\n    },\n  }\n})\n```\n```html\n\u003csome-component v-if=\"$mq.onlyForRetina()\"\u003e\u003c/some-component\u003e\n\u003csome-component v-show=\"$mq.resize \u0026\u0026 $mq.fackAbove(800)\"\u003e\u003c/some-component\u003e\n```\n\n## Variables\nThe plugin allows you to add custom variables in the vue  \u003cbr/\u003e\nAll variables are available in the ``$mv`` (mv = media variables)\n\n### Example\n```javascript\nVue.use(vMediaQuery.default, {\n  variables: {\n    hd: 1920,\n    sm: '1240px'\n  }\n})\n```\n```html\n\u003csome-component v-show=\"$mq.resize \u0026\u0026 $mq.between([$mv.sm, $mv.hd])\"\u003e\u003c/some-component\u003e\n```\n\n## Names $mq and $mv\nIf u don't like names ``$mq`` and ``$mv`` u can change them\n\n### Example\n```javascript\nVue.use(vMediaQuery.default, {\n  nameSpace: {\n    methods: $$myMethods, // default $mq\n    variables: __myVariables, // default $mv\n  },\n  variables: {\n    hd: 1920,\n  }\n})\n```\n```html\n\u003csome-component v-show=\"$$myMethods.resize \u0026\u0026 $$myMethods.above(__myVariables.hd)\"\u003e\u003c/some-component\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAStaroverov%2Fv-media-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAStaroverov%2Fv-media-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAStaroverov%2Fv-media-query/lists"}