{"id":16181256,"url":"https://github.com/kaosat-dev/most-gestures","last_synced_at":"2025-03-19T01:31:10.688Z","repository":{"id":17558910,"uuid":"78889565","full_name":"kaosat-dev/most-gestures","owner":"kaosat-dev","description":"unified desktop/mobile high level pointer gestures, using most.js","archived":false,"fork":false,"pushed_at":"2021-03-01T06:15:37.000Z","size":54,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-28T13:50:14.550Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kaosat-dev.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":"2017-01-13T21:50:54.000Z","updated_at":"2020-01-08T21:38:11.000Z","dependencies_parsed_at":"2022-07-26T18:15:12.927Z","dependency_job_id":null,"html_url":"https://github.com/kaosat-dev/most-gestures","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaosat-dev%2Fmost-gestures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaosat-dev%2Fmost-gestures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaosat-dev%2Fmost-gestures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaosat-dev%2Fmost-gestures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaosat-dev","download_url":"https://codeload.github.com/kaosat-dev/most-gestures/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243960361,"owners_count":20375102,"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-10-10T06:24:21.590Z","updated_at":"2025-03-19T01:31:10.124Z","avatar_url":"https://github.com/kaosat-dev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# most-gestures\n\n[![GitHub version](https://badge.fury.io/gh/kaosat-dev%2Fmost-gestures.svg)](https://badge.fury.io/gh/kaosat-dev%2Fmost-gestures)\n[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)\n[![Build Status](https://travis-ci.org/kaosat-dev/most-gestures.svg)](https://travis-ci.org/kaosat-dev/most-gestures)\n[![Dependency Status](https://david-dm.org/kaosat-dev/most-gestures.svg)](https://david-dm.org/kaosat-dev/most-gestures)\n[![devDependency Status](https://david-dm.org/kaosat-dev/most-gestures/dev-status.svg)](https://david-dm.org/kaosat-dev/most-gestures#info=devDependencies)\n\n\n\u003e unified desktop/mobile high level pointer gestures, using most.js\n\nThis is a set of pointer gesture helpers, unifying pointer apis accross browsers \u0026 mobile/desktop\nworks (and manually tested ) in :\n- Chrome (desktop \u0026 mobile, MacOS \u0026 Android)\n- Firefox\n- Safari (desktop \u0026 mobile , MacOs \u0026 IOS)\n- Ios \u0026 Android web views\n\nIt\n- is coded in es6\n- uses most.js observables\n- provides relatively high level tools : ie taps, zooms , drags\n\n## Table of Contents\n\n- [Background](#background)\n- [Installation](#installation)\n- [Usage](#usage)\n- [API](#api)\n- [Contribute](#contribute)\n- [License](#license)\n\n## Installation\n\n\n```\nnpm install most-gestures\n```\n\n## Usage\n\n```javascript\nimport {pointerGestures} from 'most-gestures'\n\nconst element = document.getElementById(\"foo\")\nconst gestures = pointerGestures(element)\n\n//or alternatively\nconst element = document.getElementById(\"foo\")\nconst baseInteractions = baseInteractionsFromEvents(element)\nconst gestures = pointerGestures(baseInteractions)\n\n//now you can use:\n/*gestures.taps : tap/click once \u0026 release quickly\ngestures.drags: press, keep pressed \u0026 move around\nzooms: mouse wheel \u0026 pinch zoom alike\npointerMoves: simple moves\n*/\n\n//each one of those is an observable , so to react on taps you can do:\ngestures.taps.forEach(function(e){\n  console.log('tapped',e)\n  })\n\n```\n\n\n## API\n\nthe module exposes two main functions:\n\n### baseInteractionsFromEvents(element)\n\nthis creates an object containing the low level streams (mouseDowns$, mouseUps$ etc)\nfrom a DOM element, you usually don't want to use this directly, use the following\nfunction instead.\n\n**options** allows you to refine the gestures by modifying the following parameters:\n\u003e Note: these will also get passed along correctly if set on the pointerGestures function below\n- passiveEventsHandlers: true:  Whenever possible make event listeners passive \n (see here https://developers.google.com/web/updates/2016/06/passive-event-listeners for more details)\n- preventScroll: true : Prevent all forms of scrolling on the target element\n- preventMenu: true: Prevent default right click menu on the target element\n\n### pointerGestures(baseInteractionsOrElement, options)\n\nyou can either pass in a reference to a dom element or the output from `baseInteractionsFromEvents(element)`\n\nwhat you are likely interested in, is pointerGestures:\n\n- gestures.presses (used as a basis for the two below)\n- gestures.taps : quick press/tap \u0026 release\n- gestures.holds : press/tap for a long time (defined by the longPressDelay)\u0026 release\n- gestures.drags : press \u0026 move before releasing\n- gestures.zooms : pinch , scrollwheel etc\n\nthey are all observables , so [the power is yours](https://github.com/cujojs/most/blob/master/docs/api.md) !\n\n**options** allows you to refine the gestures by modifying the following parameters:\n - multiTapDelay: time in ms between multiple taps\n - longPressDelay (default: 250) : time in ms after which a **HOLD** is emitted\n - maxStaticDeltaSqr (default: 100): maximum delta (in pixels squared) above which we consider a pointer to have moved\n - zoomMultiplier: (default: 200): zoomFactor for normalized interactions across browsers\n - pinchThreshold: (default: 4000) The minimum amount in pixels squared the inputs must move until it is fired.\n - pixelRatio : (default: window.pixelRatio if available)\n\n\n\nexamples :\n\n```javascript\ngestures.drags.forEach(function(e){\n  console.log('dragged',e)\n  })\n```\n\n### custom gestures:\n\nyou can also easily define your custom gestures, based on the existing ones: using\nmap, filter etc on the observables\n\n```javascript\nconst singleTaps$ = taps$.filter(x =\u003e x.nb === 1).map(e =\u003e e.list).map(e =\u003e e[0])\nconst doubleTaps$ = taps$.filter(x =\u003e x.nb === 2).map(e =\u003e e.list).map(e =\u003e e[0])\n```\n\n\n## Contribute\n\nPRs accepted.\n\nSmall note: If editing the Readme, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.\n\n\n## License\n\n[The MIT License (MIT)](https://github.com/kaosat-dev/most-gestures/blob/master/LICENSE)\n(unless specified otherwise)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaosat-dev%2Fmost-gestures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaosat-dev%2Fmost-gestures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaosat-dev%2Fmost-gestures/lists"}