Moousture 1.0

A mouse gesture library written soley in javascript with power and flexiblity to mould itself for you. Implemented on Mootools following the Object Oriented standards. Library is aimed to set out a future framework for mouse guesters for any browser including modern mobile devices.



Details

Author
Zohaib Sibte Hassan
Current version
1.0
GitHub
maxpert/moousture
Downloads
1668
Category
Utilities
Tags
Report
GitHub Issues

Releases


Dependencies

  • _self_/_current_: Moousture (Core js library)

How to use

Create a guesture matcher, currently there are only two gesture objects Moousture.LevenMatcher, and Moousture.ReducedLevenMatcher.

var gstr = new Moousture.ReducedLevenMatcher();

Add gesture vectors to matcher object, (see details below in Create your own gestures).

gstr.addGesture([3,2,1,0,7,6,5,4], ccwCircle);

Guesture callback function takes one parameter error recieved from matching algorithm. Threshold that value (if required) to make your gestures more sleek.

function ccwCircle(error){
    if(error <= 0.6)
        doFoo();
    return ;
}

Create a probe object that will probe the pointing device. Currently there is a mouse probe that take the $(element) to probe for. So passing a div id will cause the probe to trigger events only when they occur on the passed DOM element.

probe = new Moousture.MouseProbe($(document));

Create a recoder object to record the movement , maxSteps and minSteps in options object will specify the maximum and minimum number of steps to be recorded, and macher is required matcher object to trigger the appropriate gesture.

recorder = new Moousture.Recorder({maxSteps: 20, minSteps: 8, matcher: gstr});

Create a monitor specifying the interval to poll and the amount of error allowed for gesture in pixels.

monitor = new Moousture.Monitor(30, 2);

Finally start the monitor.

monitor.start(probe, recorder);

You can stop the gesture triggering any time by calling .stop() of monitor object.

monitor.stop();

Arbitrary Section

You can find more details on official website: http://neofreeman.freepgs.com/Moousture/ Its based on simplicity. Three major concepts.

  • A probe, which probes the pointing device. Currently there is a Moousture.MouseProbe (P.S. It already supports iPhone).
  • A monitor, which tests the stability of probed device on given intervals and accordingly notifies Moousture events (onStable, onUnstable, onMove).
  • A Moousture recorder class that records the mouse movements and invoke the guesture object passed to it.

Discuss

A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.

Found a bug in this plugin? Please report it this repository's Github Issues.

blog comments powered by Disqus