@tdb/util
Version:
Shared helpers and utilities.
33 lines (28 loc) • 629 B
text/typescript
import { IS_BROWSER } from '../../constants';
let isInitialized = false;
/**
* Initializes fast-click removing the 300ms delay
* after clicks on mobile devices.
*
* https://github.com/ftlabs/fastclick
*
*/
export function fastClick() {
if (isInitialized || !IS_BROWSER) {
return false;
}
// Initialize the library.
if ('addEventListener' in document) {
const FastClick = require('fastclick');
document.addEventListener(
'DOMContentLoaded',
function() {
FastClick.attach(document.body);
},
false,
);
}
// Finish up.
isInitialized = true;
return true;
}