{"id":13989837,"url":"https://github.com/chenghaoc/scrollbear","last_synced_at":"2025-07-22T11:31:53.371Z","repository":{"id":102380975,"uuid":"55903865","full_name":"chenghaoc/scrollbear","owner":"chenghaoc","description":"A modern tool that maintains scroll position when images loaded","archived":false,"fork":false,"pushed_at":"2017-07-26T09:25:25.000Z","size":1810,"stargazers_count":517,"open_issues_count":1,"forks_count":16,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-07-05T22:48:18.111Z","etag":null,"topics":["dom","javascript","view"],"latest_commit_sha":null,"homepage":"https://glass-analytics.github.io/scrollbear/","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/chenghaoc.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-04-10T14:33:11.000Z","updated_at":"2024-11-29T13:42:35.000Z","dependencies_parsed_at":"2023-05-28T07:45:16.869Z","dependency_job_id":null,"html_url":"https://github.com/chenghaoc/scrollbear","commit_stats":null,"previous_names":["changbenny/scrollbear"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/chenghaoc/scrollbear","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenghaoc%2Fscrollbear","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenghaoc%2Fscrollbear/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenghaoc%2Fscrollbear/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenghaoc%2Fscrollbear/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenghaoc","download_url":"https://codeload.github.com/chenghaoc/scrollbear/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenghaoc%2Fscrollbear/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266483785,"owners_count":23936419,"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-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["dom","javascript","view"],"created_at":"2024-08-09T13:02:06.527Z","updated_at":"2025-07-22T11:31:51.604Z","avatar_url":"https://github.com/chenghaoc.png","language":"JavaScript","readme":"# [Scrollbear](http://changbenny.github.io/scrollbear/)\n\n\u003ca href='https://coveralls.io/github/changbenny/scrollbear?branch=master'\u003e\n  \u003cimg src='https://img.shields.io/coveralls/changbenny/scrollbear.svg'\u003e\n\u003c/a\u003e\n\u003cimg src='https://img.shields.io/npm/v/scrollbear.svg'\u003e\n\u003cimg src='https://img.shields.io/npm/l/scrollbear.svg?maxAge=2592000'\u003e\n\n[Scrollbear](http://changbenny.github.io/scrollbear/) is a tool that maintains the container scroll position when images loaded. Scrollbear is suitable in blog platforms where exist many photos and images. When images loaded, the scroll position will *jump* and cause a unfriendly experience. Scrollbear will trace the container height and maintain the scroll position when the images loaded and container height change.\n\n** Since Google Chrome launch scolling anchor feature, there's no difference with or without Scrollbear in Chrome browser.\n\n## [Demo](http://changbenny.github.io/scrollbear/demo/static_img.html)\n\n## Installation\n\n`npm install scrollbear`\n\n## Usage\n\n```html\n\u003cdiv id='scroll' style='overflow: scroll;'\u003e\n    \u003cdiv id='container'\u003e\n        \u003cp\u003elong content\u003c/p\u003e\n        \u003cp\u003elong content\u003c/p\u003e\n    \u003c/div\u003e\n\u003c/div\u003e\n\u003cscript src='scrollbear.js'\u003e\u003c/script\u003e\n```\n\n```javascript\nScrollbear.start(document.getElementById('scroll'))\n```\n\n## API\n\n#### Scrollbear.start(target, [changedItems])\n\n`target` is the DOM where scroll bar exists (Normally is the container of contents), normally the direct child node of this target will be a DOM with really long content (such as the content of blog articles).\n\n`changeItems` is optional. It is useful when images is lazy loading into your page. In such case, you can specify the *placeholder* of images. When images is lazy-loaded, the height of placeholder will change, and trigger the Scrollbear to justify the scroll position.\n\n#### Scrollbear.stop()\n\n#### Scrollbear.onChange(callback)\n\n`callback` function will be called when Scrollbear detects container height changes and adjust the scroll position. The first param of `callback` will be the target which height changed. \n\n\n## Development\n\nInstall development dependency\n\n```sh\nnpm install\n```\n\nBuild\n\n```sh\ngulp\n```\n\nTest\n\n```\nnpm test\n```\n\n## Contribute\n\nIssues or PR are all Welcome!\n\n## License\n\nMIT\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenghaoc%2Fscrollbear","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenghaoc%2Fscrollbear","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenghaoc%2Fscrollbear/lists"}