From fd3ca31e44374adb550b72fe37e1c2e56db0f392 Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Thu, 31 Jan 2019 15:56:16 +0000 Subject: [PATCH] Add adjustment for padding missed from previous The work done to stack sticky elements closer together only effected the stack when stuck to the top/bottom edge: https://github.com/alphagov/notifications-admin/commit/707c426b9aa5b7730ac49dff21763b27507d08bd It should have included the same for when a stack of sticky elements is stopped at the end of it's scroll area. This adds code to deal with that. --- app/assets/javascripts/stick-to-window-when-scrolling.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/stick-to-window-when-scrolling.js b/app/assets/javascripts/stick-to-window-when-scrolling.js index 5b1568b52..b3ebdef1d 100644 --- a/app/assets/javascripts/stick-to-window-when-scrolling.js +++ b/app/assets/javascripts/stick-to-window-when-scrolling.js @@ -197,10 +197,12 @@ // if next to opposite edge to the one the dialog is stuck to, no offset if (elIdx === (els.length - 1)) { return 0; } - // get all els between this one and the opposite edge - els = els.slice(elIdx + 1); + // make els all those from this one to the window edge + els = els.slice(elIdx); + // get all els between this one and the window edge + elsBetween = els.slice(1); - return this._getTotalHeight(els); + return this._getTotalHeight(elsBetween) - this._getPaddingBetweenEls(els); }, // checks total height of all this._sticky elements against a height // unsticks each that won't fit and marks them as unstickable