From f730f1c5e5a49350bbf698da3f83abd6bffee986 Mon Sep 17 00:00:00 2001 From: dekieret Date: Wed, 2 Mar 2016 14:54:20 +0100 Subject: [PATCH] Added suppress function. The fire function won't be executed when ouibounce is suppress untill suppress(false) is called. --- source/ouibounce.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/ouibounce.js b/source/ouibounce.js index 1bb73dd..70f0b7e 100644 --- a/source/ouibounce.js +++ b/source/ouibounce.js @@ -82,7 +82,7 @@ function ouibounce(el, custom_config) { // You can use ouibounce without passing an element // https://github.com/carlsednaoui/ouibounce/issues/30 function fire() { - if (isDisabled()) { return; } + if (isDisabled() || supressed) { return; } if (el) { el.style.display = 'block'; } @@ -123,11 +123,18 @@ function ouibounce(el, custom_config) { _html.removeEventListener('keydown', handleKeydown); } + var supressed; + function suppress(value) { + supressed = value; + } + return { fire: fire, disable: disable, - isDisabled: isDisabled + isDisabled: isDisabled, + suppress: suppress }; + } /*exported ouibounce */