{"id":15235702,"url":"https://github.com/mjdease/preact-resize-observer","last_synced_at":"2025-04-10T10:21:57.608Z","repository":{"id":57329543,"uuid":"124682976","full_name":"mjdease/preact-resize-observer","owner":"mjdease","description":"Element resize event for Preact","archived":false,"fork":false,"pushed_at":"2018-09-24T03:13:27.000Z","size":4323,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T07:45:28.438Z","etag":null,"topics":["preact","preact-components","resize-observer","typescript"],"latest_commit_sha":null,"homepage":"https://mjdease.github.io/preact-resize-observer/demo/","language":"TypeScript","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/mjdease.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-03-10T17:54:30.000Z","updated_at":"2022-01-17T04:41:51.000Z","dependencies_parsed_at":"2022-09-14T22:54:04.739Z","dependency_job_id":null,"html_url":"https://github.com/mjdease/preact-resize-observer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjdease%2Fpreact-resize-observer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjdease%2Fpreact-resize-observer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjdease%2Fpreact-resize-observer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjdease%2Fpreact-resize-observer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjdease","download_url":"https://codeload.github.com/mjdease/preact-resize-observer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199080,"owners_count":21063641,"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":["preact","preact-components","resize-observer","typescript"],"created_at":"2024-09-29T08:05:24.640Z","updated_at":"2025-04-10T10:21:57.584Z","avatar_url":"https://github.com/mjdease.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"preact-resize-observer\n---\n\n[![Build Status](https://travis-ci.com/mjdease/preact-resize-observer.svg?branch=master)](https://travis-ci.com/mjdease/preact-resize-observer)\n[![codecov](https://codecov.io/gh/mjdease/preact-resize-observer/branch/master/graph/badge.svg)](https://codecov.io/gh/mjdease/preact-resize-observer)\n[![npm version](https://badge.fury.io/js/preact-resize-observer.svg)](https://badge.fury.io/js/preact-resize-observer)\n\nWatch an element for changes to its size. Supports modern browsers and IE9+.\n\nThis is a Preact component wrapper for the excellent [ResizeObserver polyfill](https://github.com/que-etc/resize-observer-polyfill).\n\n[Demo](https://mjdease.github.io/preact-resize-observer/demo/)\n\n### Installation\n\n`npm install preact-resize-observer`\n\n### Example\n\n```js\nimport { Component } from 'preact';\nimport ResizeObserver from 'preact-resize-observer';\n\nexport default class App extends Component {\n  handleResize = (width, height) =\u003e {\n    // Current width and height of the .fluid-content element\n    console.log(`width: ${width}, height: ${height}`)\n  }\n\n  render(props) {\n    return (\n      \u003cResizeObserver class=\"fluid-content\" onResize={this.handleResize}\u003e\n        \u003cp\u003e{props.content}\u003c/p\u003e\n      \u003c/ResizeObserver\u003e\n    );\n  }\n}\n```\n\n### Prop Types\n\n| Property | Type | Default | Description |\n|:---|:---|:---:|:---|\n| `onResize` | Function | | Required. Callback invoked whenever the observed element changes size. `(width: number, height: number): void` |\n| `horizontal` | boolean | `true` | Observe changes to the width |\n| `vertical` | boolean | `true` | Observe changes to the height |\n| `tag` | string | `'div'` | The HTML tag to render this component as |\n| `element` | Element | | The element to observe the size of. If not specified the element rendered by this component will be observed |\n| `initial` | boolean | `true` | Controls if `onResize` will be invoked when the element is first observed (typically on mount). Set to `false` to disable this initial call.\n| `innerRef` | function | | Get reference to the rendered element. `(element: Element): void`\n\nChangelog\n---\n1.0.0 (24/06/2018)\n* Change component design to be used as part of regular page markup:\n  * Change to observe size of self by default (previously parent was observed)\n  * Add support to render children\n  * Add `tag` prop to control the tag to render as\n  * Add `innerRef` prop to get a reference to the actual DOM node\n  * Change prop names to avoid clashing with standard HTML attributes\n* Distribute ES module\n\n0.1.1 (31/05/2018)\n* Fixed package dependencies\n* Fixed component types for Preact 8.2.9\n\n0.1.0 (20/03/2018)\n* Initial Release\n\nLicence\n---\n`preact-resize-obsever` is available under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjdease%2Fpreact-resize-observer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjdease%2Fpreact-resize-observer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjdease%2Fpreact-resize-observer/lists"}