{"id":15767900,"url":"https://github.com/bubkoo/detect-element-resize","last_synced_at":"2025-07-26T10:04:26.443Z","repository":{"id":24756352,"uuid":"28169247","full_name":"bubkoo/detect-element-resize","owner":"bubkoo","description":"A Cross-Browser, Event-based, Element Resize Detection","archived":false,"fork":false,"pushed_at":"2014-12-19T07:25:12.000Z","size":164,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-21T13:43:24.651Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bubkoo.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":"2014-12-18T05:09:47.000Z","updated_at":"2014-12-19T07:25:13.000Z","dependencies_parsed_at":"2022-07-25T14:02:24.242Z","dependency_job_id":null,"html_url":"https://github.com/bubkoo/detect-element-resize","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bubkoo/detect-element-resize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fdetect-element-resize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fdetect-element-resize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fdetect-element-resize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fdetect-element-resize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bubkoo","download_url":"https://codeload.github.com/bubkoo/detect-element-resize/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fdetect-element-resize/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267149578,"owners_count":24043444,"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","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-04T13:41:41.994Z","updated_at":"2025-07-26T10:04:26.396Z","avatar_url":"https://github.com/bubkoo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Detect element resize\n\n实现来源于 https://github.com/sdecima/javascript-detect-element-resize。这里做了模块化封装。\n暴露出 `config` 方法，避免代码中的关键帧动画名和样式名与业务代码中定义的冲突，并优化部分代码。\n\n## 特性\n\n- 基于 `scroll` 事件来检测元素大小改变，而不是基于 Timer，性能很好\n- 除了能检测 JavaScript 引起的元素大小改变，还能检测由 CSS(:hover, animations) 引起的大小改变\n\n## 兼容\n\n- Chrome\n- Firefox\n- IE11 及一下（在 IE11 10 9 8 7 上做过测试）\n\n## 注意\n\n该实现会在页面头部引入必要的 CSS 样式，在被检测的元素内部引入一些 `div` 标签，所以需要注意这些引入的第三方代码是否会与自身的业务代码冲突。\n\n## API\n\n### `config(options)`\n\n这里的配置项都是为了不与业务代码冲突所设置的，所以如非必要请不要调用。\n\n下面是 `options` 的默认值：\n\n```js\noptions = {\n    animationName: 'resizeAnimation', // 关键帧动画名\n    className: 'resize-trigger'       // div 样式名\n}\n```\n\n### `addResizeListener(element, callback)`\n\n添加事件回调，可以多次调用绑定多个事件处理函数。\n\n### `removeResizeListener(element, callback)`\n\n移除元素上指定的元素大小改变的回调函数。\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbubkoo%2Fdetect-element-resize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbubkoo%2Fdetect-element-resize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbubkoo%2Fdetect-element-resize/lists"}