Alex-D/Cookies-EU-banner

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

sebastian-marinescu opened this issue · 0 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.