{"id":17275125,"url":"https://github.com/daun/resize-start-stop","last_synced_at":"2025-03-26T13:42:55.864Z","repository":{"id":57141435,"uuid":"282984623","full_name":"daun/resize-start-stop","owner":"daun","description":"Debounced `resizestart` and `resizestop` events on the window","archived":false,"fork":false,"pushed_at":"2020-08-01T10:25:01.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-05T09:33:15.381Z","etag":null,"topics":["debounce","events","javascript","resize","resizestart","resizestop","window"],"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/daun.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":"2020-07-27T18:37:59.000Z","updated_at":"2020-08-01T10:24:59.000Z","dependencies_parsed_at":"2022-09-05T18:40:20.636Z","dependency_job_id":null,"html_url":"https://github.com/daun/resize-start-stop","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Fresize-start-stop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Fresize-start-stop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Fresize-start-stop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daun%2Fresize-start-stop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daun","download_url":"https://codeload.github.com/daun/resize-start-stop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245667113,"owners_count":20652899,"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":["debounce","events","javascript","resize","resizestart","resizestop","window"],"created_at":"2024-10-15T08:55:29.219Z","updated_at":"2025-03-26T13:42:55.846Z","avatar_url":"https://github.com/daun.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# resizestart \u0026 resizestop events\n\n[![NPM version](https://img.shields.io/npm/v/resize-start-stop)](https://www.npmjs.com/package/resize-start-stop)\n[![Bundle size](https://img.shields.io/bundlephobia/minzip/resize-start-stop?label=size)](https://bundlephobia.com/result?p=resize-start-stop)\n[![GitHub license](https://img.shields.io/github/license/daun/resize-start-stop)](./LICENSE)\n![Travis Build](https://img.shields.io/travis/com/daun/resize-start-stop)\n![Codecov](https://img.shields.io/codecov/c/github/daun/resize-start-stop)\n\nDebounced resize events: know when a user started or stopped resizing the window.\n\n## Why would I need this?\n\n![Debounce](./docs/debounce.svg)\n\nThe window's `resize` event is triggered continously and often. That's bad news\nfor performance. In most cases, what we really want to know is when the user has started or stopped resizing the window.\n\n## What does it do?\n\nThis package will trigger debounced resize events on the window. Simply replace\nyour old `resize` event listeners with more performant `resizestart` and\n`resizestop` listeners.\n\n## Installation\n\n```bash\nnpm install resize-start-stop\n```\n\n## Usage\n\nImport and call `bindResizeEvents()` to install debounced `resizestart` and\n`resizestop` events on the window.\n\n```js\nimport { bindResizeEvents } from 'resize-start-stop'\n\nbindResizeEvents()\n\nwindow.addEventListener('resizestart', () =\u003e { console.log('Resizing') })\nwindow.addEventListener('resizestop', () =\u003e { console.log('Resized') })\n```\n\n### Toggle class name during resize\n\nThe package includes a helper for the most common use case: toggling a class\nname on the `html` element during resize. Great for disabling transitions\nand animations while crossing breakpoint boundaries.\n\n```js\nimport { toggleClassDuringResize } from 'resize-start-stop'\n\ntoggleClassDuringResize()\n```\n\n```css\nhtml.is-resizing * {\n  transition: none !important;\n}\n```\n\nAll options and their defaults:\n\n```js\ntoggleClassDuringResize({\n  className: 'is-resizing',\n  element: document.documentElement,\n  wait: 200\n})\n```\n\n### Cleaning up\n\nIf you don't need the installed events anymore, import and call\n`unbindResizeEvents()`.\n\n```js\nimport { bindResizeEvents, unbindResizeEvents } from 'resize-start-stop'\n\n// Bind events\nbindResizeEvents()\n\n// Unbind at later stage\nunbindResizeEvents()\n```\n\n### In the browser\n\nIf you don't have the luxury of using a bundler, you can also\nsimply include the script tag and call it a day.\n\n```html\n\u003cscript src=\"https://unpkg.com/resize-start-stop\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  resizeStartStop.bindResizeEvents()\n\u003c/script\u003e\n```\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaun%2Fresize-start-stop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaun%2Fresize-start-stop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaun%2Fresize-start-stop/lists"}