{"id":16594856,"url":"https://github.com/symind/vue-sliding-button","last_synced_at":"2025-03-21T13:32:01.587Z","repository":{"id":33274905,"uuid":"125441689","full_name":"SyMind/vue-sliding-button","owner":"SyMind","description":"一个 Vue 的滑动按钮组件，拥有优雅的惯性与回弹动画。","archived":false,"fork":false,"pushed_at":"2022-12-03T22:01:08.000Z","size":2676,"stargazers_count":24,"open_issues_count":17,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-20T05:17:53.951Z","etag":null,"topics":["vue","vuejs"],"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/SyMind.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-16T00:21:01.000Z","updated_at":"2024-05-11T12:26:22.000Z","dependencies_parsed_at":"2023-01-15T00:30:54.563Z","dependency_job_id":null,"html_url":"https://github.com/SyMind/vue-sliding-button","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyMind%2Fvue-sliding-button","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyMind%2Fvue-sliding-button/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyMind%2Fvue-sliding-button/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyMind%2Fvue-sliding-button/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SyMind","download_url":"https://codeload.github.com/SyMind/vue-sliding-button/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221815697,"owners_count":16885207,"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":["vue","vuejs"],"created_at":"2024-10-11T23:47:45.124Z","updated_at":"2024-10-28T10:13:23.302Z","avatar_url":"https://github.com/SyMind.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vue-better-slider\n\n\u003e 一个 Vue 的滑动按钮组件，拥有优雅的惯性与回弹动画，有关动画方面的处理借鉴 better-scroll 的实现。\n\n[在线例子](https://symind.github.io/vue-better-slider/index.html)\n\n![二维码](https://symind.github.io/static/image/vue-sliding-button-qr-code.png)\n\n# 起步\n## 安装\n``` bash\nnpm i --save vue-sliding-button\n```\n\n## 引入\n``` js\nimport Vue from 'vue'\nimport SlidingButton from 'vue-sliding-button'\n\nVue.use(SlidingButton)\n```\n## 使用\n``` html\n\u003ctemplate\u003e\n    \u003cdiv\u003e\n      \u003cbetter-slider\u003e\n        \u003cdiv slot=\"front\" class=\"front\"\u003e\n          前面的内容\n        \u003c/div\u003e\n        \u003cdiv slot=\"back\" class=\"back\"\u003e\n          后面的内容\n        \u003c/div\u003e\n      \u003c/better-slider\u003e\n    \u003c/div\u003e\n\u003c/template\u003e\n\u003cscript\u003e\n\n\u003c/script\u003e\n```\n\n# 原理\n## 布局\n![布局](https://symind.github.io/static/image/vue-sliding-button-layout.png)\n\n绿色部分为 wrapper，它拥有两个子元素为 back 和 front，它的高度会被 front 撑起。黄色部分为 back，它使用**绝对定位**，它的高度与 wrapper 相同，值得注意的是为了提高性能，back 在用户触摸该控件是才被插入。front 与 back 同级。\n## 关闭\n组件提供关闭动画，调用组件的 close 方法使用，可以通过监听 clickBackEvent 等事件，通过传入的组件引用已调用该方法。需要注意的是，该方法并不会删除该组件，可以通过监听 closeTransitionEndEvent 事件，在其中进行自己的处理。\n# 选项\nSlidingButton 支持很多属性。\n## right\n* 类型：Number\n* 默认值：80\n* 作用：从左向右滑动时，右边展示宽度\n## left\n* 类型：Number\n* 默认值：80\n* 作用：从右向左滑动时，左边展示宽度\n## rightBackgroundColor\n* 类型：Number\n* 默认值：80\n* 作用：从左向右滑动时，组件底色，主要用于关闭动画\n## leftBackgroundColor\n* 类型：Number\n* 默认值：0\n* 作用：从右向左滑动时，组件底色，主要用于关闭动画\n## momentum\n* 类型：Boolean\n* 默认值：true\n* 作用：表示是否开启惯性动画\n## momentumTime\n* 类型：Number\n* 默认值：100\n* 作用：表示惯性动画持续时间\n## deceleration\n* 类型：Number\n* 默认值：0.01\n* 作用：表示惯性动画的减速度\n## closeTime\n* 类型：Number\n* 默认值：300\n* 作用：表示关闭动画的持续时间\n## trigger\n* 类型：Boolean\n* 默认值：true\n* 作用：该属性为 true 或 false 并无区别，只要该值发生改变，且用户没有触摸该组件时，就会将组件的 front 置于原始位置。当在列表中使用多个该组件时，可以使用该属性。\n# 事件\n注意：event 是事件原生参数，component 是指向该组件的引用。\n## clickBackEvent\n* 参数：{ Object }.{ event, component }\n* 触发时机：用户点击 back 时\n## clickFrontEvent\n* 参数：{ Object }.{ event, component }\n* 触发时机：用户点击 front 时\n## touchStartEvent\n* 参数：{ Object }.{ event, component }\n* 触发时机：用户开始触摸该组件时\n## closeTransitionEndEvent\n* 参数：{ Object }.{ event, component }\n* 触发时机：关闭动画结束时调用\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymind%2Fvue-sliding-button","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsymind%2Fvue-sliding-button","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymind%2Fvue-sliding-button/lists"}