New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tonic-mouse-handler

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tonic-mouse-handler - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

.travis.yml

42

docs/api/MouseHandler.md
# MouseHandler
This class allow the user to ease the management of complex mouse interaction
without having to duplicate the coordinate system management and drag logic
across several projects.
This class eases the management of complex mouse and touch
interactions without having to duplicate coordinate-system management
and drag logic across several projects.
## Constructor( domElement )
## constructor(domElement, [options])
This will attach the touch and mouse listener to a given DOM element.
Attaches the touch and mouse listener to a given DOM element.
Options is an object with the keys _pan_ and _pinch_, associated with is an object with
the key _threshold_. You can overwrite _threshold_ or add additional [gesture options](http://hammerjs.github.io/recognizer-pan/) which get
passed to TonicMouseHandler's hammerjs instance.
## enablePinch(enable)
You can enable or disable the __pinch__ handling by calling that method with
true or false. By default, the mouse handler will listen to that event.
Enables or disables the __pinch__ handling by calling that method with
true or false. By default, the mouse handler will be enabled with the event.
## setModifier(modifier)
This method let you override the event modifier so you can simulate a ALT + drag
Overrides the event modifier so you can simulate a ALT + drag
on a mobile device as well.
The modifier code are as follow and use the bitwise logic.
The modifiers are as follows and use the associated bitwise logic.

@@ -31,11 +34,11 @@ - __NONE__: 0

This will detach any listener and free the resources.
The instance is not supposed to work after that.
Detach any listener and free the resources.
The instance should not work after that.
## on(type, callback): subscription
This allow you to bind your own listener to the high level events.
Bind your own listeners to high level events.
We rely on monologue.js for subscribing to the events.
The callback should look like
The callback should look like:

@@ -48,3 +51,3 @@ ```js

The event should look like
The corresponding event should look like:

@@ -82,3 +85,3 @@ ```js

The set of possible topic that you can listen to are:
The set of possible events that you can listen to are:

@@ -93,4 +96,4 @@ - __drag__

This allow to set a modifier by a long press.
The modifiers is an array of modifier that we want to loop over for every long
Sets a modifier by a long press.
Modifiers is an array of modifiers that we want to loop over for every long
press.

@@ -104,6 +107,7 @@

This helper method ease the binding of several listeners to the current
Helper method to ease the binding of several listeners to the current
MouseHandler instance.
The code should explain what that method is doing.
Equivalent to:
```js

@@ -110,0 +114,0 @@ function(listeners) {

@@ -51,3 +51,3 @@ ---

{% highlight bash %}
~ $ npm install {{ site.project }} --save
$ npm install {{ site.project }} --save
{% endhighlight %}

@@ -59,7 +59,7 @@

{% highlight bash %}
~ $ git clone git@github.com:{{site.repository}}.git
~ $ cd {{site.project}}
~/{{site.project}} $ npm install
~/{{site.project}} $ npm test
# => Browse on http://localhost:3000
$ git clone git@github.com:{{site.repository}}.git
$ cd {{site.project}}
$ npm install
$ npm test
# => Open http://localhost:3000 in a browser
{% endhighlight %}

@@ -66,0 +66,0 @@

// Module dependencies and constants
var Monologue = require('monologue.js'),
Hammer = require('hammerjs'),
merge = require('mout/src/object/merge'),
handlerCount = 0,

@@ -43,3 +44,13 @@ Modifier = { NONE:0, ALT:1, META:2, SHIFT:4, CTRL:8 },

export default function MouseHandler(domElement) {
export default function MouseHandler(domElement, options) {
var defaultOptions = {
pan: {
threshold: 0
},
pinch: {
threshold: 0
}
};
options = merge(defaultOptions, options);
this.id = 'mouse_handler_' + (++handlerCount);

@@ -122,2 +133,6 @@ this.el = domElement;

// set hammer options
this.hammer.get('pan').set(options.pan);
this.hammer.get('pinch').set(options.pinch);
// Listen to hammer events

@@ -124,0 +139,0 @@ this.hammer.on('tap', (e) => {

{
"name": "tonic-mouse-handler",
"description": "JavaScript library used to simplify mouse handling via a consistent API across modern browser.",
"version": "0.0.5",
"version": "0.0.6",
"license": "BSD-3-Clause",

@@ -13,7 +13,7 @@ "main": "./lib/MouseHandler.js",

"hammerjs": "2.0.4",
"monologue.js": "0.3.3"
"monologue.js": "0.3.3",
"mout": "0.11.0"
},
"devDependencies": {
"tonic-site-generator": "Kitware/tonic-site-generator",
"jshint": "2.8.0",

@@ -34,6 +34,4 @@ "jshint-loader": "0.8.3",

"build:release": "webpack -p",
"www": "tonic-site-generator site.config.js",
"www:http" : "tonic-site-generator site.config.js --local-test && serve docs/www",
"www:http": "tonic-site-generator site.config.js --local-test && serve docs/www",
"pretest": "npm run build",

@@ -40,0 +38,0 @@ "test": "cp dist/* tests/ && serve ./tests"

@@ -1,7 +0,12 @@

## Simple mouse interaction handler [Home page](http://kitware.github.io/tonic-mouse-handler/)
# Simple mouse interaction handler
[![Build Status](https://travis-ci.org/Kitware/tonic-mouse-handler.svg)](https://travis-ci.org/Kitware/tonic-mouse-handler)
[![Dependency Status](https://david-dm.org/kitware/tonic-mouse-handler.svg)](https://david-dm.org/kitware/tonic-mouse-handler)
[Home page](http://kitware.github.io/tonic-mouse-handler/)
Tonic Mouse Handler provides a concise and consistent API for mouse interaction
with proper coordinate system and drag callback.
with proper coordinate system and drag callback.
To learn more what _Tonic Mouse Handler_ can do for you read the
To learn more what _Tonic Mouse Handler_ can do for you read the
[Quick start](http://kitware.github.io/tonic-mouse-handler/docs/home/) guide.

@@ -14,7 +19,7 @@

#### Licensing
### Licensing
**tonic-mouse-handler** is licensed under [BSD Clause 3](LICENSE).
#### Getting Involved
### Getting Involved

@@ -21,0 +26,0 @@ Fork our repository and do great things. At [Kitware](http://www.kitware.com),

@@ -22,4 +22,8 @@ module.exports = {

"timezone": "America/Denver",
"project": "tonic-mouse-handler"
"project": "tonic-mouse-handler",
"status": [
{"subject": "api_stability", "status": "fair", "color": "green"},
{"subject": "feature_complete", "status": "★★★★☆", "color": "green"}
]
}
};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc