/touchcode

Trigger special actions when user clic or touch a specific sequence of points in the screen

Primary LanguageJavaScript

Touchcode

Touchcode lets you easily perform custom actions after a sequence of clic / touch is executed.

Usage

Load the script:

<script type="text/javascript" src="path/to/touchcode.js"></script>

And add your touchcode:

// Create a new Touchode instance ...
var tc = new Touchcode();

// ... and initialize it with your sequence, padding and you callback
tc.init([{x: 100, y: 100}, {x: 300, y: 400}, ...], 50, function(){
  console.log('Touchcode: You did it !');
});

Documentation

touchcode.init(sequence, padding, callback)

Initilization of the Touchcode.

Param Type Description
sequence Array Sequence to execute.
padding Number The padding for the bouding box of your points.
callback function The callback function to be executed when the sequence is over.

TODO

  • Implement a timeout to reset the counter.
  • Define built-ins zone (e.g "top-left", "center", "bottom", "bottom-right", etc...)