Using: drupal 7.

In CSS of my theme, the "body" element has a "padding-top" value as this:

body {
    padding-top: 2em;
}

This leads to two side-effects wtih this (great) module.

1st side-effect: when the banner is shown in the top, there's a gap between the top of the page and the banner itself, as shown here:

1st  gap image

this is a trascurable side-effect and some could say "it's not a bug it's a feature", so I fully accept it. :-)

The second side-effect is that, when I click on a "deny" button ("no, grazie" == "no, thanks") both in a opt-in or opt-out mode, this is the result:

2nd gap image

The #sliding-popup element is placed on top: -111px; but since there's a padding-top of 2em, -111px is not enough and the last line is still shown. And the gap between the last line and the body, is never hidden (until the next page visit).

Now, since I cannot remove that padding-top setting for the body element without problems around all the theme, I need a solution to really hide the #sliding-popup element after clicking the "no, thanks" button.

At the moment, the only workaround I found is to patch the eu_cookie_compliance.js script, adding a "location.reload()" in the Drupal.eu_cookie_compliance.declineAction function, line 255. Something like this:

  Drupal.eu_cookie_compliance.declineAction = function () {
    Drupal.eu_cookie_compliance.setStatus(0);
    let popup = $('#sliding-popup');
    if (popup.hasClass('sliding-popup-top')) {
      popup.animate({ top: popup.outerHeight() * -1 }).trigger('eu_cookie_compliance_popup_close');
	  location.reload();
    }
    [...]

And it works - I mean: the sliding-popup is still shown "too low" but since a page reload is forced, it's no more rendered. I think the same thing happens when I click on the "I agree" button (same problem with the position.. but as far as I can see, a reload is forced after a status change).

I understand this is just a temporary workaround, maybe somebody can find a better way to solve [my|this] problem?

Comments

francoud created an issue. See original summary.

svenryen’s picture

I'll take a look. Right now there's quite a lot on my plate for this module, so patches are also welcome.

francoud’s picture

Thanks 2svenryen, great job. Tell me if I can help with further information about this problem :)

svenryen’s picture

Hi @francoud - I finally got around to looking into your report.
Not only did I have to consider padding-top, also margin-top (in your case 0) had to be added to the calculations.

You can upgrade now to the -dev version, or wait for 7.30.

  • svenryen authored 56a1132 on 8.x-1.x
    Issue #2985986 by svenryen, francoud: body top-padding not computed
    

  • svenryen authored 47e9f26 on 7.x-1.x
    Issue #2985986 by svenryen, francoud: body top-padding not computed
    
svenryen’s picture

Status: Active » Fixed

  • svenryen authored d54d981 on 8.x-1.x
    Issue #2985986 by svenryen, francoud: body top-padding not computed
    

  • svenryen authored b0958c5 on 7.x-1.x
    Issue #2985986 by svenryen, francoud: body top-padding not computed
    

  • svenryen authored 47e9f26 on 7.x-2.x
    Issue #2985986 by svenryen, francoud: body top-padding not computed
    
  • svenryen authored b0958c5 on 7.x-2.x
    Issue #2985986 by svenryen, francoud: body top-padding not computed
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.