{"id":20163825,"url":"https://github.com/systemlight/micro-touch","last_synced_at":"2025-09-14T23:57:06.514Z","repository":{"id":42833169,"uuid":"265161376","full_name":"SystemLight/micro-touch","owner":"SystemLight","description":":point_left:  Super basic mobile gesture support tool. 【微型移动端手势支持工具】","archived":false,"fork":false,"pushed_at":"2023-08-03T06:15:48.000Z","size":859,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-11T04:58:10.741Z","etag":null,"topics":["es6","javascript","js","mobile","rotate","scale","touch","touchgesture"],"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/SystemLight.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-19T06:13:09.000Z","updated_at":"2022-07-03T11:57:18.000Z","dependencies_parsed_at":"2024-11-14T00:32:04.830Z","dependency_job_id":"b63b5401-7aab-4cb6-b4c0-22bee951ac76","html_url":"https://github.com/SystemLight/micro-touch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SystemLight/micro-touch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SystemLight%2Fmicro-touch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SystemLight%2Fmicro-touch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SystemLight%2Fmicro-touch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SystemLight%2Fmicro-touch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SystemLight","download_url":"https://codeload.github.com/SystemLight/micro-touch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SystemLight%2Fmicro-touch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275185370,"owners_count":25419919,"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-09-14T02:00:10.474Z","response_time":75,"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":["es6","javascript","js","mobile","rotate","scale","touch","touchgesture"],"created_at":"2024-11-14T00:31:58.960Z","updated_at":"2025-09-14T23:57:06.493Z","avatar_url":"https://github.com/SystemLight.png","language":"JavaScript","readme":"# micro-touch\n\n[![NPM version](https://img.shields.io/npm/v/micro-touch.svg)](https://www.npmjs.com/package/micro-touch)\n\nSuper basic mobile gesture support tool.   \nNPM page: https://www.npmjs.com/package/micro-touch\n\n# Installation\n\n```\nnpm install micro-touch --save\n```\n\n# User Guide\n\n```\nimport {TouchGesture} from \"micro-touch\";\n\ntou = new TouchGesture(DOM);\nlet t2d = new Transform2D(tou.el)\n// tou.on(\"tap\", tap);\n// tou.on(\"longTap\", longTap);\n// tou.on(\"doubleTap\", doubleTap);\n// tou.on(\"pressMove\", function (e) {\n//     let {moveDistance, startDistance} = e;\n//     console.log(moveDistance, startDistance);\n// });\ntou.on(\"pinch\", function (e) {\n    let {pointAngle,startAngle,pointSpace,startSpace,scale,rotate} = e;\n    t2d.setRotate(rotate);\n})\n```\n\n```\n结合mmicro-transform2d实现拖拽阻力\n\nlet pullN = 0.2;\n\nlet tg = new TouchGesture(divDom.current);\nlet t2d = new Transform2D(divDom.current);\nt2d.setTranslate(50, 0);\n\ntg.on(\"tapDown\", function () {\n    divDom.current.style.removeProperty(\"transition\");\n    t2d.setTranslate(50, 0);\n});\n\ntg.on(\"pressMove\", function (e) {\n    let {moveDistance: {x, y, d}} = e;\n    let [nowX, nowY] = t2d.getTranslate();\n\n    if (nowY \u003e 50) {\n        y *= pullN;\n    }\n\n    t2d.setTranslate(50, nowY + y);\n});\n\ntg.on(\"tapUp\", function () {\n    divDom.current.style.transition = \"500ms\";\n    t2d.setTranslate(50, 0);\n});\n```\n\n# Note\n\n传入一个DOM对象，对其进行方法监听\n\n- new TouchGesture(DOM)\n\n- on(gesture,callback) : 注册事件监听回调函数\n  - 'tap' : 元素被单击\n  - 'doubleTap' : 元素被双击\n  - 'longTap' : 长按元素一秒\n  - 'pressMove' : 移动元素\n  - 'pinch' : 双指缩放或者旋转时触发\n  - \"tapDown\" | \"tapMove\" | \"tapUp\" : 等同于touchstart，touchmove，touchend，但是拓展了事件属性\n\n- off() : 取消注册的回调函数\n- destroy() : 销毁注册实例\n- interval(lastTime: number, duration: number = 500) : Promise对象判定给定时间是否和当前时间满足间隔\n- getMove(p1: point, p2: point) : 获取两个点之间的距离对象\n- getAngle(move: move) : 解析move对象，返回角度值（弧度制）\n- getMiddlePoint(p1: point, p2: point) : 获取两个点之间的中点坐标\n- radian2angle() : 弧度转角度\n- angle2radian() : 角度转弧度\n\n\n# Resources\n\nYou can read [micro-touch Documentation](https://github.com/SystemLight/micro-touch) online for more information.\n\n# License\n\nmicro-touch uses the MIT license, see LICENSE file for the details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystemlight%2Fmicro-touch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsystemlight%2Fmicro-touch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystemlight%2Fmicro-touch/lists"}