Skip to content

Commit

Permalink
updated documentation and fixed keywords getting overwritten.
Browse files Browse the repository at this point in the history
  • Loading branch information
munkychop committed Sep 10, 2014
1 parent 29d6579 commit 73c4db6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 30 deletions.
75 changes: 49 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,56 @@
#SwiftClick
# SwiftClick

SwiftClick is a library created to eliminate the 300ms click event delay on touch devices that support orientation change.
SwiftClick is a library created to eliminate the 300ms click event delay on touch devices that support orientation change and is designed to be super lightweight.

It was designed for basic element types that are typically used in modern interactive development and so obscure bugs found in older browsers for elements such as form, select, and textarea are not a big concern at this time, so workarounds for these should be implemented separately from SwiftClick, if necessary.

###Teeny-tiny
Just over 500 bytes minified & gzipped :-)
### Teeny-tiny
Only 957 bytes minified & gzipped :-)

###Usage
## Usage

Firstly, grab either the [minified](https://raw2.github.com/tmwagency/swiftclick/master/js/dist/swiftclick.min.js), or [non-minified](https://raw2.github.com/tmwagency/swiftclick/master/js/libs/swiftclick.js) source from Github, or install via Bower using the following command in your command prompt:
Firstly, grab either the [minified](https://raw2.github.com/tmwagency/swiftclick/master/js/dist/swiftclick.min.js), or [non-minified](https://raw2.github.com/tmwagency/swiftclick/master/js/libs/swiftclick.js) source from Github.

bower install swiftclick
Alternatively, if you can use npm with the following command in your command prompt:

####Include SwiftClick in your application
<script type="application/javascript" src="path/to/swiftclick.min.js"></script>
```sh
npm install swiftclick --save
```

Or you can install via Bower instead, if that's your thing:

####Setup SwiftClick
```sh
bower install swiftclick
```

Setting up SwiftClick is a very easy process, requiring instances to be attached to a context element. Click events from all elements within the context element are automatically captured and converted to touch events when necessary.
### Include SwiftClick in your application
```html
<script type="application/javascript" src="path/to/swiftclick.min.js"></script>
```

If using CommonJS then simply require SwiftClick as per usual:

```javascript
var SwiftClick = require("swiftclick");
```

### Setup SwiftClick

Setting up SwiftClick is a very easy process, which mirrors that of FastClick in that instances must be attached to a context element. Touch events from all elements within the context element are automatically captured and converted to click events when necessary, minus the delay.

Start by creating a reference to a new instance of SwiftClick using the 'attach' helper method and attach it to a context element. Attaching to document.body is easiest if you only need a single instance of SwiftClick:

var swiftclick = SwiftClick.attach (document.body);
```js
var swiftclick = SwiftClick.attach(document.body);
```

If necessary, multiple instances of SwiftClick can be created for specific context elements which, although not really necessary in most cases, can sometimes be useful for optimising applications with a large amount of HTML:

var navigationSwiftClick = SwiftClick.attach (someNavElement);
var uiSwiftClick = SwiftClick.attach (someOtherElement);
```js
var navigationSwiftClick = SwiftClick.attach(someNavElement);
var uiSwiftClick = SwiftClick.attach(someOtherElement);
```

####Default Elements
### Default Elements
Once attached, by default SwiftClick will track events originating from the following element types:

- `<a>`
Expand All @@ -39,23 +59,26 @@ Once attached, by default SwiftClick will track events originating from the foll
- `<button>`


####Adding non-default element types
### Adding non-default element types
If necessary you can make SwiftClick track events originating from additional element types by adding an array of node names. This requires a reference to an instance of SwiftClick:

var swiftclick = SwiftClick.attach (someElement);
swiftclick.addNodeNamesToTrack (["p", "h1", "nav"]);
```js
var swiftclick = SwiftClick.attach(someElement);
swiftclick.addNodeNamesToTrack(["p", "h1", "nav"]);
```

####Replacing all stored node names to track
### Replacing all stored node names to track

var swiftclick = SwiftClick.attach (someElement);
swiftclick.replaceNodeNamesToTrack (["a", "div"]);
```js
var swiftclick = SwiftClick.attach(someElement);
swiftclick.replaceNodeNamesToTrack(["a", "div", "h1"]);
```

Doing this will remove all default node names, as well as any that have been added, and replace them with the node names within the array that is passed in, resulting in only the new node names being tracked.


####Automatically disabled when not needed
### Automatically disabled when not needed
SwiftClick only intercepts events for touch devices that support orientation change, otherwise it just sits there looking pretty.


###Credits
SwiftClick was developed by [Ivan Hayes](https://github.com/munkychop) and is heavily based on [FastClick](https://github.com/ftlabs/fastclick) (developed by [FT Labs](https://github.com/ftlabs/fastclick)).
## About the Project
SwiftClick was developed and is currently maintained by [Ivan Hayes](https://twitter.com/munkychop).
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swiftclick",
"version": "1.1.4",
"version": "1.1.5",
"homepage": "https://github.com/tmwagency/swiftclick",
"authors": [
"Ivan Hayes <@munkychop>"
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "swiftclick",
"title": "SwiftClick",
"description": "Eliminates the 300ms click event delay on touch devices that support orientation change",
"version": "1.1.4",
"version": "1.1.5",
"homepage": "https://github.com/tmwagency/swiftclick",
"author": {
"name": "Ivan Hayes",
Expand Down Expand Up @@ -35,6 +35,5 @@
"grunt-contrib-uglify": "~0.2.4",
"grunt-contrib-watch": "~0.5.3",
"grunt-devtools": "~0.1.0-7"
},
"keywords": []
}
}

0 comments on commit 73c4db6

Please sign in to comment.