Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,36 @@ Just follow these simple steps to enable touch events in your jQuery UI app:
```

_Tested on iPad, iPhone, Android and other touch-enabled mobile devices._

## Using Touch Punch with RequireJS

jQuery UI 1.11+ is required for using Touch Punch with RequireJS.

### Configuration

The base path of jQuery UI have to be configured in the require config json:

```javascript
requirejs.config({
paths: {
// for example with bower
'jquery-ui': 'bower_components/jquery-ui/ui',
// ... other dependencies
}
});
```

### Example

To create an touch friendly slider, just require all dependencies like the following example:

```javascript
require([
'jquery',
'jquery.ui.touch-punch',
'jquery-ui/slider'
], function($) {
// init the slider
$('input').slider();
});
```
18 changes: 16 additions & 2 deletions jquery.ui.touch-punch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,20 @@
* jquery.ui.widget.js
* jquery.ui.mouse.js
*/
(function ($) {
(function(factory) {
if (typeof define === 'function' && define.amd) {

// AMD. Register as an anonymous module.
define([
'jquery',
'jquery-ui/mouse'
], factory);
} else {

// Browser globals
factory(jQuery);
}
}(function($) {

// Detect touch support
$.support.touch = 'ontouchend' in document;
Expand Down Expand Up @@ -177,4 +190,5 @@
_mouseDestroy.call(self);
};

})(jQuery);
return $;
}));
2 changes: 1 addition & 1 deletion jquery.ui.touch-punch.min.js

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