{"id":29926692,"url":"https://github.com/ecomfe/saber-scroll","last_synced_at":"2025-08-02T12:43:18.392Z","repository":{"id":11462738,"uuid":"13926995","full_name":"ecomfe/saber-scroll","owner":"ecomfe","description":"为移动端页面提供区域滚动功能","archived":false,"fork":false,"pushed_at":"2015-10-13T06:50:59.000Z","size":318,"stargazers_count":9,"open_issues_count":2,"forks_count":7,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-25T08:05:21.236Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ecomfe.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-28T13:44:31.000Z","updated_at":"2018-04-03T09:55:50.000Z","dependencies_parsed_at":"2022-08-29T22:40:45.935Z","dependency_job_id":null,"html_url":"https://github.com/ecomfe/saber-scroll","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/ecomfe/saber-scroll","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fsaber-scroll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fsaber-scroll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fsaber-scroll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fsaber-scroll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ecomfe","download_url":"https://codeload.github.com/ecomfe/saber-scroll/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecomfe%2Fsaber-scroll/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268392199,"owners_count":24243297,"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-08-02T02:00:12.353Z","response_time":74,"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":"2025-08-02T12:42:48.908Z","updated_at":"2025-08-02T12:43:18.373Z","avatar_url":"https://github.com/ecomfe.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"saber-scroll\n===\n\n为移动端页面提供区域滚动功能\n\n提供元素内容垂直、水平滚动。颗粒化功能，以插件形式提供增强功能，方便组合，文件大小可控\n\n## Installation\n\n通过 [edp](https://github.com/ecomfe/edp) 引入模块：\n\n```sh\nedp import saber-scroll\n```\n\n## Usage\n\n```js\nvar scroll = require('saber-scroll');\nvar scroller = scroll(document.getElementById('wrapper'));\nscroller.on('change', function (e) {\n    console.log(e.left, e.top);\n});\n```\n\n__只滚动区域的第一个子元素__，如果想让区域中的所有元素都能滚动请添加包裹元素，比如这样：\n\n```html\n\u003cdiv class=\"content\"\u003e\n    \u003cdiv class=\"wrapper\"\u003e\n        ...\n    \u003c/div\u003e\n\u003c/div\u003e\n```\n\n## API\n\n* [Methods](#methods)\n* [Classes](#classes)\n* [Plugins](#plugins)\n\n### Methods\n\n#### scroll(ele[, options])\n\n使元素内容可滚动\n\n* **ele** `{HTMLElemnt}` 内容需要滚动的元素或者对应的id\n* **options** `{Object=}` 初始化参数\n    * **horizontal** `{boolean=}` 是否可以水平滚动，默认为`true`\n    * **vertical** `{boolean=}` 是否可以垂直滚动，默认为`true`\n    * **overflow** `{boolean=}` 是否可以超出滚动范围，默认为`true`\n* _return_ `{Scroller}` [Scroller](doc/scroller.md)滚动对象\n\n滚动条是以插件形式实现的，在使用时除了设置`options.scrollbar`外，还需要引入`saber-scroll/plugin/scrollbar`模块\n\n### Classes\n\n* [Scroller](doc/scroller.md) [scroll()](#scrollele-options)创建的滚动对象\n\n### Plugins\n\n* [scrollbar](doc/plugin/scrollbar.md) 为滚动区域添加滚动条\n* [overflowHint](doc/plugin/overflowHint.md) 提供到达或者超出滚动范围的提示样式\n\n插件用于丰富功能，需要额外引入并设置相应的属性，例如：\n\n```js\nvar scroll = require('saber-scroll');\n// 引入scrollbar插件\nrequire('saber-scroll/plugin/scrollbar');\n\nvar scroller = scroll(\n    ele,\n    {\n        // 启用scrollbar插件\n        scrollbar: true\n    }\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecomfe%2Fsaber-scroll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fecomfe%2Fsaber-scroll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecomfe%2Fsaber-scroll/lists"}