Alex-D / Cookies-EU-banner

1kb vanilla JS script which manages cookies consent banner display like asked by GDPR

Home Page:http://alex-d.github.io/Cookies-EU-banner/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Animating out // wait-remove with "before-remove" class

sebastian-marinescu opened this issue · comments

Hi @Alex-D,
first of all thanks a lot for this great, simple and beautiful script.

I'd like to animate the banner in, and out - in both cases: on accept & on reject.
Right now this is not possible, as their is no indication of the upcoming DOM-removal.

I'm suggesting setting a class in the removeBanner method, like this:

    removeBanner: function(wait) {
      var banner = document.getElementById("cookies-eu-banner");
      banner.classList.add("before-remove");
      setTimeout(function() {
        if (banner && banner.parentNode) {
          banner.parentNode.removeChild(banner);
        }
      }, wait);
    }

Here is a demo of how I'm going to use it:
https://codepen.io/sebastian-marinescu/pen/MWwGLwY?editors=0010

If you are okay with this, I'm preparing a PR.