-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
29 lines (26 loc) · 845 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* Set `touch-action` to `document.body` when supported
* or load FastClick from CDN and use it as Polyfill.
* https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action
*
* @param {Object} [opts]
* {String} src - link to fastclick
* {String} val - value of touchAction property
*/
module.exports = function touchAction(opts) {
var s
if (!opts) opts = {}
if (!opts.src) opts.src = 'https://cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js'
if (!opts.val) opts.val = 'manipulation'
if ('touchAction' in document.body.style) {
document.body.style.touchAction = opts.val
} else {
s = document.createElement('script')
s.src = opts.src
s.async = true
s.onload = function onload() {
window.FastClick.attach(document.body)
}
document.body.appendChild(s)
}
}