{"id":16441081,"url":"https://github.com/phegman/v-scroll-lock","last_synced_at":"2025-04-05T07:06:30.348Z","repository":{"id":35880746,"uuid":"143375958","full_name":"phegman/v-scroll-lock","owner":"phegman","description":"A Vue.js directive for body scroll locking without breaking scrolling of a target element.","archived":false,"fork":false,"pushed_at":"2022-12-11T12:13:38.000Z","size":1182,"stargazers_count":185,"open_issues_count":28,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-25T01:27:48.886Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phegman.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":"2018-08-03T04:03:59.000Z","updated_at":"2024-09-12T00:17:06.000Z","dependencies_parsed_at":"2023-01-16T08:45:22.128Z","dependency_job_id":null,"html_url":"https://github.com/phegman/v-scroll-lock","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phegman%2Fv-scroll-lock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phegman%2Fv-scroll-lock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phegman%2Fv-scroll-lock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phegman%2Fv-scroll-lock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phegman","download_url":"https://codeload.github.com/phegman/v-scroll-lock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299832,"owners_count":20916190,"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-10-11T09:13:45.193Z","updated_at":"2025-04-05T07:06:30.327Z","avatar_url":"https://github.com/phegman.png","language":"TypeScript","readme":"[![npm](https://img.shields.io/npm/dw/localeval.svg)](https://www.npmjs.com/package/v-scroll-lock)\n[![Build Status](https://travis-ci.org/phegman/v-scroll-lock.svg?branch=master)](https://travis-ci.org/phegman/v-scroll-lock)\n\n# v-scroll-lock\n\nA Vue.js directive for body scroll locking (for iOS Mobile and Tablet, Android, desktop Safari/Chrome/Firefox) without breaking scrolling of a target element (eg. modal/lightbox/flyouts/nav-menus). Built on top of [https://github.com/willmcpo/body-scroll-lock](https://github.com/willmcpo/body-scroll-lock)\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Demo](#demo)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Support](#support)\n- [Contributing](#contributing)\n\n## Overview\n\nPreventing the body from scrolling when you have a modal/lightbox/flyout/nav-menu open on all devices can be a huge pain. This package wraps [https://github.com/willmcpo/body-scroll-lock](https://github.com/willmcpo/body-scroll-lock) into an easy to use Vue.js directive.\n\n## Demo\n\nDemo can be viewed here: [http://v-scroll-lock.peterhegman.com/](https://v-scroll-lock.peterhegman.com/)  \nSource code for demo can be viewed in `src/Demo.vue`\n\n## Installation\n\n### Module Bundler (Webpack, Rollup, etc)\n\n#### Yarn\n\n```bash\nyarn add v-scroll-lock\n```\n\n#### NPM\n\n```bash\nnpm install v-scroll-lock --save\n```\n\n#### Install the Directive\n\n```js\nimport VScrollLock from 'v-scroll-lock'\n\nVue.use(VScrollLock)\n```\n\n### [Vue CDN](https://vuejs.org/v2/guide/#Getting-Started)\n\nDownload latest `v-scroll-lock.min.js` from [https://github.com/phegman/v-scroll-lock/releases](https://github.com/phegman/v-scroll-lock/releases)\n\nInclude using a `\u003cscript\u003e` tag\n\n```html\n\u003cscript src=\"v-scroll-lock.min.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\nOnce the plugin is installed the `v-scroll-lock` directive can be used in any of your components. When the value of the directive is `true` scrolling will be locked on all elements **except** the element the directive is bound to.\n\nHere is an example of how you may implement it in a basic modal. Please note the below example is to demonstrate usage of the `v-scroll-lock` directive and is not a complete implementation of a modal. See `src/components/Modal.vue` for a more in depth example.\n\n```vue\n\u003ctemplate\u003e\n  \u003cdiv class=\"modal\" v-if=\"open\"\u003e\n    \u003cbutton @click=\"closeModal\"\u003eX\u003c/button\u003e\n    \u003cdiv class=\"modal-content\" v-scroll-lock=\"open\"\u003e\n      \u003cp\u003eA bunch of scrollable modal content\u003c/p\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\nexport default {\n  name: 'Modal',\n  data() {\n    return {\n      open: false,\n    }\n  },\n  methods: {\n    openModal() {\n      this.open = true\n    },\n    closeModal() {\n      this.open = false\n    },\n  },\n}\n\u003c/script\u003e\n```\n\n### [body-scroll-lock](https://github.com/willmcpo/body-scroll-lock#options) options\n\nOptions can be passed when installing the directive:\n\n```js\nimport VScrollLock from 'v-scroll-lock'\n\nVue.use(VScrollLock, {\n  bodyScrollOptions: {\n    reserveScrollBarGap: true,\n  },\n})\n```\n\nSee [https://github.com/willmcpo/body-scroll-lock#options](https://github.com/willmcpo/body-scroll-lock#options) for full list of options.\n\n### Providing Your Own Version of [body-scroll-lock](https://github.com/willmcpo/body-scroll-lock)\n\nTo make using this directive easier [body-scroll-lock](https://github.com/willmcpo/body-scroll-lock) is included in the package. In the case that you would like to use a version different than the packaged version this can be specified in the plugin options. Also note that `v-scroll-lock-no-dep.esm.js` should be imported to prevent duplicate code in your bundle. See example below:\n\n```js\nimport VScrollLock from 'v-scroll-lock/dist/v-scroll-lock-no-dep.esm'\nimport { enableBodyScroll, disableBodyScroll } from 'body-scroll-lock'\n\nVue.use(VScrollLock, {\n  enableBodyScroll,\n  disableBodyScroll,\n})\n```\n\n## Support\n\nPlease [open an issue](https://github.com/phegman/v-scroll-lock/issues/new/) for support.\n\n## Contributing\n\nPlease contribute using [Github Flow](https://guides.github.com/introduction/flow/). Create a branch, add commits, and [open a pull request](https://github.com/phegman/v-scroll-lock/compare).\n","funding_links":[],"categories":["UI Utilities [🔝](#readme)","UI实用程序","Components \u0026 Libraries","UI Utilities"],"sub_categories":["滚动","UI Utilities","Scroll"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphegman%2Fv-scroll-lock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphegman%2Fv-scroll-lock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphegman%2Fv-scroll-lock/lists"}