From d1c1635c624fad2aab599a1d79e2b48f81a663fa Mon Sep 17 00:00:00 2001 From: Amauri CHAMPEAUX Date: Sun, 7 Jun 2015 18:48:23 +0200 Subject: [PATCH] New feature! Services are allowed when the user scroll down more than 2x is screen height --- css/tarteaucitron.css | 1 + tarteaucitron.js | 40 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/css/tarteaucitron.css b/css/tarteaucitron.css index 838e3ba..d0f24c8 100644 --- a/css/tarteaucitron.css +++ b/css/tarteaucitron.css @@ -358,6 +358,7 @@ left: 0; position: fixed; width: 0; + z-index: 2147483644; } /*** diff --git a/tarteaucitron.js b/tarteaucitron.js index 1aa42c9..93aff60 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -39,15 +39,15 @@ var tarteaucitron = { }, true); }, false); window.addEventListener("scroll", function () { - var scrollPos = window.pageYOffset || document.documentElement.scrollTop, + var scrollPos = window.pageYOffset || document.documentElement.scrollTop, heightPosition; - if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) { - if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') { + if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) { + if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') { heightPosition = document.getElementById('tarteaucitronAlertBig').offsetHeight + 'px'; - + if (scrollPos > (screen.height * 2)) { - tarteaucitron.userInterface.respondAll(true); - } else if (scrollPos > (screen.height / 2)) { + tarteaucitron.userInterface.respondAll(true); + } else if (scrollPos > (screen.height / 2)) { document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '' + tarteaucitron.lang.alertBigScroll + ' ' + tarteaucitron.lang.alertBig; } @@ -56,10 +56,10 @@ var tarteaucitron = { } else { document.getElementById('tarteaucitronPercentage').style.bottom = heightPosition; } - document.getElementById('tarteaucitronPercentage').style.width = ((100 / (screen.height * 2)) * scrollPos) + '%'; - } - } - }, false); + document.getElementById('tarteaucitronPercentage').style.width = ((100 / (screen.height * 2)) * scrollPos) + '%'; + } + } + }, false); window.addEventListener("keydown", function (evt) { if (evt.keyCode === 27) { tarteaucitron.userInterface.closePanel(); @@ -93,15 +93,15 @@ var tarteaucitron = { }, true); }); window.attachEvent("onscroll", function () { - var scrollPos = window.pageYOffset || document.documentElement.scrollTop, + var scrollPos = window.pageYOffset || document.documentElement.scrollTop, heightPosition; - if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) { - if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') { + if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) { + if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') { heightPosition = document.getElementById('tarteaucitronAlertBig').offsetHeight + 'px'; - + if (scrollPos > (screen.height * 2)) { - tarteaucitron.userInterface.respondAll(true); - } else if (scrollPos > (screen.height / 2)) { + tarteaucitron.userInterface.respondAll(true); + } else if (scrollPos > (screen.height / 2)) { document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '' + tarteaucitron.lang.alertBigScroll + ' ' + tarteaucitron.lang.alertBig; } if (tarteaucitron.orientation === 'top') { @@ -109,10 +109,10 @@ var tarteaucitron = { } else { document.getElementById('tarteaucitronPercentage').style.bottom = heightPosition; } - document.getElementById('tarteaucitronPercentage').style.width = ((100 / (screen.height * 2)) * scrollPos) + '%'; - } - } - }); + document.getElementById('tarteaucitronPercentage').style.width = ((100 / (screen.height * 2)) * scrollPos) + '%'; + } + } + }); window.attachEvent("onkeydown", function (evt) { if (evt.keyCode === 27) { tarteaucitron.userInterface.closePanel();