mattermost-mobile/app/utils/tap.js
2018-06-19 19:14:50 -04:00

19 lines
464 B
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
const doublePressDelay = 300;
export function preventDoubleTap(func) {
let canPressWrapped = true;
return (...args) => {
if (canPressWrapped) {
canPressWrapped = false;
func(...args);
setTimeout(() => {
canPressWrapped = true;
}, doublePressDelay);
}
};
}