mattermost-mobile/app/utils/tap.js
Harrison Healey 80c09b588d MM-9647 Replaced usage of preventDoubleTap with wrapWithPreventDoubleTap (#1471)
* MM-9467 Replaced usage of preventDoubleTap with wrapWithPreventDoubleTap

* MM-9467 Renamed wrapWithPreventDoubleTap to preventDoubleTap
2018-03-02 11:22:37 +00:00

19 lines
464 B
JavaScript

// Copyright (c) 2017-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);
}
};
}