{"id":20698803,"url":"https://github.com/rwson/toucher","last_synced_at":"2025-04-22T21:47:10.782Z","repository":{"id":87105666,"uuid":"65879808","full_name":"rwson/Toucher","owner":"rwson","description":"移动端手势库","archived":false,"fork":false,"pushed_at":"2017-02-14T01:01:59.000Z","size":158,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T19:11:21.285Z","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/rwson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-17T05:54:51.000Z","updated_at":"2020-04-17T15:29:34.000Z","dependencies_parsed_at":"2023-07-04T22:48:04.723Z","dependency_job_id":null,"html_url":"https://github.com/rwson/Toucher","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/rwson%2FToucher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rwson%2FToucher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rwson%2FToucher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rwson%2FToucher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rwson","download_url":"https://codeload.github.com/rwson/Toucher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250331046,"owners_count":21413092,"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":[],"created_at":"2024-11-17T00:26:59.946Z","updated_at":"2025-04-22T21:47:10.772Z","avatar_url":"https://github.com/rwson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Toucher\n\n移动端手势库\n\n#### API\n        \n    Toucher(\"#node\").config(Object).on(Object)\n\n        或者\n        \n    var toucher = Toucher(\"#node\");\n    toucher.config(Object);\n    toucher.on(name, callback);\n    \n通过\n\n    var toucher = Toucher(css selector);\n    \n来构造一个Toucher对象\n\n用\n\n    toucher.config(Object)\n    \n来配置相关事件的触发条件\n\n\n    touch.on(name, callbck);\n    \n或\n\n    touch.on(name, target, callbck);\n\n来绑定事件\n\n#### 完整示例\n\n    //  HTML\n    \u003cdiv id=\"toucher\"\u003e\n        \u003cdiv id=\"event\"\u003e\u003c/div\u003e\n        \u003cul\u003e\n            \u003cli class=\"list-item\"\u003e\u003c/li\u003e\n            \u003cli class=\"list-item\"\u003e\u003c/li\u003e\n            \u003cli class=\"list-item\"\u003e\u003c/li\u003e\n            \u003cli class=\"list-item\"\u003e\u003c/li\u003e\n            \u003cli class=\"list-item\"\u003e\u003c/li\u003e\n            \u003cli class=\"list-item\"\u003e\u003c/li\u003e\n        \u003c/ul\u003e\n    \u003c/div\u003e\n    \n    \n    //  javascript\n    var toucher = Toucher(\"#toucher\");\n    \n    //  回调函数会在任何时候被执行,只要event.target为\u003cdiv\u003e#toucher或者其子元素\n    toucher.on(\"singleTap\", function(ev) {\n        //  ...\n    });\n    \n    //  只有当event.target为\u003cdiv\u003e#event的时候,才会执行后面的回调函数\n    toucher.on(\"singleTap\", \"#event\", function(ev) {\n        //  ...\n    });\n    \n    //  只有当event.target为\u003cli\u003e.list-item的时候,才会执行后面的回调函数\n    toucher.on(\"singleTap\", document.querySelector(\".list-item\"), function(ev) {\n        //  ...\n    });\n    \n\n####  支持的配置项(config)和事件列表(on)\n\n- config\n\n属性 | 含义  |  类型\n---|---|---\nlongTapTime | 触发longTap事件的时间(毫秒),默认700ms |  Number\ndoubleTapTime | 在多少毫秒内连续点击两次屏幕,触发doubleTap,默认400ms  | Number\n\n- on\n\n###### 两个参数\n\nname属性 | 含义 |  callback类型\n---|---|---\nsingleTap | 轻击(单个手指) |  Fucntion\ndoubleTap | 手指放到屏幕(单个手指) |  Fucntion\nlongTap | 长按 |  Fucntion\nswipe | 手指在屏幕上移动 |  Fucntion\nswipeStart | 滑动开始(只触发一次) |  Fucntion\nswipeEnd | 滑动结束(只触发一次) |  Fucntion\nswipeUp | 上滑 |  Fucntion\nswipeRight | 右滑 |  Fucntion\nswipeDown | 下滑 |  Fucntion\nswipeLeft | 左滑 |  Fucntion\npinch | 缩放 |  Fucntion\nrotate | 旋转 |  Fucntion\n\n###### 三个参数\n\nname和callback和上表一样\n\ntarget可以为具体的css selector, 也可以为具体的DOM元素(document.querySelector(selector)之类方法获取到的)\n\n- off\n\n解除之前绑定过的代理事件(之前怎样绑定的就怎样解除)\n\n###### 例子\n\n    var toucher = Toucher(\"#div\");\n    \n    //  绑定\n    toucher.on(\"singleTap\", function(ev){});\n    \n    //  解除绑定\n    toucher.off(\"sigleTap\");\n    \n或者\n    \n    var toucher = Toucher(\"#div\");\n    \n    //  绑定\n    toucher.on(\"singleTap\", \".list-item\", function(ev){});\n    \n    //  解除绑定\n    toucher.off(\"sigleTap\", \".list-item\");\n\n#### 在线体验\n\n扫描下方二维码或者手机直接访问https://rwson.github.io/Toucher/\n\n\u003cimg src=\"img/demo.png\" width=\"50%\" height=\"50%\" /\u003e\n\n- 参考腾讯AlloyTeam手势库[AlloyFinger](https://github.com/AlloyTeam/AlloyFinger)实现\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frwson%2Ftoucher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frwson%2Ftoucher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frwson%2Ftoucher/lists"}