Skip to content

Commit

Permalink
plugin readme, flexible plugin response
Browse files Browse the repository at this point in the history
  • Loading branch information
jairajs89 committed Feb 20, 2012
1 parent 83d9964 commit 254f842
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 13 deletions.
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Touchy.js
### Because some things just need to be touched.

Touchy.js is a simple light-weight (1.64 kb compressed) JavaScript library for dealing with touch events in the browser. With no dependencies, just add the script to your page and start hacking.
Touchy.js is a simple light-weight (1.65 kb compressed) JavaScript library for dealing with touch events in the browser. With no dependencies, just add the script to your page and start hacking.


## Quick example
Expand Down Expand Up @@ -111,3 +111,38 @@ var touchMe = document.getElementById('touch-me');
Touchy(touchMe, true, callback); // For all finger events
Touchy(touchMe, true, { one: ..., two: ... }); // For multi-touch finger events
```


# Plugin support

``` javascript
// Define a plugin
Touchy.plugin('myPlugin', function (elem, settings) {
// Write your plugin here.
// This will be executed each time the plugin is applied to an element.

// 'elem' is the element being touched
// 'settings' is the the object passed during usage of the plugin

// Return an object to setup Touchy for the element.
// This is equivalent to Touchy(elem, { one: ..., two: ... });
return { one: ..., two: ... };
});

// Use a plugin
var touchMe = document.getElementById('touch-me');
Touchy(touchMe, {
myPlugin: { these: 'are', your: 'settings' }
});
```


# jQuery wrapper

``` javascript
var touchMe = document.getElementById('touch-me');
Touchy(touchMe, { one: ..., two: ... });

// This is equivalent to the following jQuery code:
$('#touch-me').touchy({ one: ..., two: ... });
```
6 changes: 5 additions & 1 deletion touchy.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,11 @@

for (var name in plugins) {
if (name in settings) {
var updates = plugins[name]( settings[name] );
var updates = plugins[name](elem, settings[name]);

if (typeof updates == 'function') {
updates = { any: updates };
}

for (var handlerType in updates) {
if (handlerType in settings) {
Expand Down
22 changes: 11 additions & 11 deletions touchy.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 254f842

Please sign in to comment.