{"_id":"touch-pinch","_rev":"4-4d5291b431a85722bca14d3fdeb36eb0","name":"touch-pinch","description":"minimal two-finger pinch gesture detection","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"touch-pinch","version":"1.0.0","description":"minimal two-finger pinch gesture detection","main":"index.js","license":"MIT","author":{"name":"Matt DesLauriers","email":"dave.des@gmail.com","url":"https://github.com/mattdesl"},"dependencies":{"dprop":"^1.0.0","events":"^1.0.2","gl-vec2":"^1.0.0","mouse-event-offset":"^3.0.2"},"devDependencies":{"budo":"^5.1.0","dom-css":"^1.1.2","garnish":"^3.2.1"},"scripts":{"test":"node test.js","start":"budo demo.js:bundle.js --live | garnish"},"keywords":["touch","pinch","detection","zoom","pan"],"repository":{"type":"git","url":"git://github.com/Jam3/touch-pinch.git"},"homepage":"https://github.com/Jam3/touch-pinch","bugs":{"url":"https://github.com/Jam3/touch-pinch/issues"},"gitHead":"73ba252f4f4da139b4654dd8eb3791cf79dd2252","_id":"touch-pinch@1.0.0","_shasum":"89bae5dd15ba76f5a5491c25f434ba38c9a23d68","_from":".","_npmVersion":"2.14.5","_nodeVersion":"0.12.7","_npmUser":{"name":"mattdesl","email":"dave.des@gmail.com"},"dist":{"shasum":"89bae5dd15ba76f5a5491c25f434ba38c9a23d68","tarball":"https://registry.npmjs.org/touch-pinch/-/touch-pinch-1.0.0.tgz","integrity":"sha512-adSH+RTrmGRM5yPxnME9+WW36J/fF3iVzY9ozI0lMf22L+Xj45cum7YgjRQDimSm4c5WoGM90O/inGkwMy5rVg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD/Yxx3gaCpaNE9q0Z8mhKeOWu+m6oGdLRiNClya1eaHwIgTJCNXVGWxZq3pbUIciyMxs7htDOQk05bbezu1rKKOsA="}]},"maintainers":[{"name":"mattdesl","email":"dave.des@gmail.com"}]},"1.0.1":{"name":"touch-pinch","version":"1.0.1","description":"minimal two-finger pinch gesture detection","main":"index.js","license":"MIT","author":{"name":"Matt DesLauriers","email":"dave.des@gmail.com","url":"https://github.com/mattdesl"},"dependencies":{"dprop":"^1.0.0","events":"^1.0.2","gl-vec2":"^1.0.0","mouse-event-offset":"^3.0.2"},"devDependencies":{"budo":"^5.1.0","dom-css":"^1.1.2","garnish":"^3.2.1"},"scripts":{"test":"node test.js","start":"budo demo.js:bundle.js --live | garnish"},"keywords":["touch","pinch","detection","zoom","pan"],"repository":{"type":"git","url":"git://github.com/Jam3/touch-pinch.git"},"homepage":"https://github.com/Jam3/touch-pinch","bugs":{"url":"https://github.com/Jam3/touch-pinch/issues"},"gitHead":"852f981ecc1d27f9712d57b519deb91fcbc0056c","_id":"touch-pinch@1.0.1","_shasum":"52f2aeee263139730570d0ccdf8d443a92b3b36d","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.4","_npmUser":{"name":"mattdesl","email":"dave.des@gmail.com"},"dist":{"shasum":"52f2aeee263139730570d0ccdf8d443a92b3b36d","tarball":"https://registry.npmjs.org/touch-pinch/-/touch-pinch-1.0.1.tgz","integrity":"sha512-If5caiHlfY2JBQYM8XWjOB4mwEidkYpjLXV6zx1uuama0lrbGNVxhzG0wSpaAdHduoGVtWKAQNoCLrgJDEnnfQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCDl+oUX/E1nHtrMkcrruxz/CxiOaTVku9tHiBCiUeBZwIhANaX7CFfWHdU7rvpWIMN5XMy/GsndQ7xlsNQO3766jdj"}]},"maintainers":[{"name":"mattdesl","email":"dave.des@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/touch-pinch-1.0.1.tgz_1487688503477_0.6800646376796067"}}},"readme":"# touch-pinch\n\n[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)\n\nA low-level utility for two-finger pinch and panning gestures.\n\n## Install\n\n```sh\nnpm install touch-pinch --save\n```\n\n## Example\n\nThe following example scales by the delta difference in a two-finger pinch gesture.\n\n```js\nvar pinch = require('touch-pinch')\n\nvar scale = 1\npinch(window)\n  .on('change', function (dist, prev) {\n    scale += (dist - prev)\n  })\n```\n\n## Usage\n\n[![NPM](https://nodei.co/npm/touch-pinch.png)](https://www.npmjs.com/package/touch-pinch)\n\n#### `pinch = touchPinch([target])`\n\nCreates a new `pinch` emitter with the optional `target` element, which defaults to `window`.\n\n### events\n\n#### `pinch.on('start', fn)`\n\nCalled when the pinch event begins; i.e. when two fingers are active on screen.\n\nCalled with `fn(distance)`, which is the initial Euclidean distance between these two points.\n\n#### `pinch.on('change', fn)`\n\nCalled when the pinch changes; i.e. one or both of the fingers in the pinch have moved.\n\nCalled with `fn(distance, prevDistance)`, where `distance` is the new Euclidean distance, and `prevDistance` is the last recorded distance. Often, you will use this delta to compute a new scale:\n\n```js\nscale += (distance - prevDistance)\n```\n\n#### `pinch.on('end', fn)`\n\nCalled when the pinch is finished; i.e. one or both of the active fingers have been lifted from the screen.\n\n#### `pinch.on('place', fn)`\n\nCalled before the pinch has started, to indicate that a new finger has been placed on screen (with a maximum of two fingers). \n\nCalled with `fn(newTouch, otherTouch)`, where `newTouch` is the new TouchEvent. `otherTouch` is the touch event that represents the other finger on screen, or `undefined` if none exists.\n\n#### `pinch.on('lift', fn)`\n\nCalled before the pinch has ended, to indicate that a previoulsy pinching finger has been lifted. \n\nCalled with `fn(removedTouch, otherTouch)`, where `removedTouch` is the TouchEvent that was removed from the screen. `otherTouch` is the touch event for the other finger on screen, or `undefined` if none exists.\n\n### members\n\n#### `pinch.pinching`\n\nA read-only boolean; `true` only if the user is currently pinching (two fingers on screen).\n\n#### `pinch.fingers`\n\nAn array of two elements, which are initially both `null` (representing \"no finger\"). The elements are the two possible fingers in a pinch event.\n\nWhen a finger is present on screen, the element in the array will contain:\n\n```js\n{\n  position: [x, y],  // the offset relative to target\n  touch: TouchEvent  // the associated event\n}\n```\n\nThe order is maintained; so if you place a finger, then place a second, then remove the first finger, `pinch.fingers` will look like this:\n\n```js\n[ null, { position, touch } ]\n```\n\n### methods\n\n#### `pinch.indexOfTouch(touchEvent)`\n\nReturns the index of `touchEvent` within the `pinch.fingers` array. This can be used to determine\n\n## License\n\nMIT, see [LICENSE.md](http://github.com/Jam3/touch-pinch/blob/master/LICENSE.md) for details.\n","maintainers":[{"name":"mattdesl","email":"dave.des@gmail.com"}],"time":{"modified":"2022-06-27T19:03:07.869Z","created":"2015-09-29T21:32:32.534Z","1.0.0":"2015-09-29T21:32:32.534Z","1.0.1":"2017-02-21T14:48:25.348Z"},"homepage":"https://github.com/Jam3/touch-pinch","keywords":["touch","pinch","detection","zoom","pan"],"repository":{"type":"git","url":"git://github.com/Jam3/touch-pinch.git"},"author":{"name":"Matt DesLauriers","email":"dave.des@gmail.com","url":"https://github.com/mattdesl"},"bugs":{"url":"https://github.com/Jam3/touch-pinch/issues"},"license":"MIT","readmeFilename":"README.md"}