dobarkod / cookie-banner

JavaScript based cookie-info banner for complying with EU cookie law
MIT License
425 stars 85 forks source link

sleepBeforeClose and Utils.sleep(milliseconds) #67

Closed webaddicto closed 6 years ago

webaddicto commented 6 years ago

Allows to set a sleep(milliseconds) before closing the cookie banner, example:

  <script type="text/javascript" id="cookiebanner"
      src="../src/cookiebanner.js"
      data-height="20px"
      data-close-text="NOooo!"
      data-font-size="16px"
      data-accept-on-click="true"
      data-effect="fade"
      data-sleep-before-close="1000"
      data-message="We use cookies to improve your browsing experience.">
  </script>

Useful to use with accept-on-scroll and accept-on-click, so the banner will wait (sleep) N milliseconds before being closed after an user has scrolled the page (accept-on-scroll) or triggered the onclick-event (accept-on-click).

zytzagoo commented 6 years ago

Can't we just use setTimeout instead of hogging the cpu?

webaddicto commented 6 years ago

Made the changes, tested and working fine: https://github.com/dobarkod/cookie-banner/pull/67/commits/dc7738aa6dec107997ca23d4d8dbe42eff761670

zytzagoo commented 6 years ago

Do you have problems with me renaming the option name (and related changes) to delay-before-close? I feel it would better describe what it does...

webaddicto commented 6 years ago

Absolutely no problem =)