From 0d349fba89697bf58d86a9b26d8ebc385d1a8417 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 20 Jul 2018 12:59:16 -0300 Subject: [PATCH] Bug 21099: Reposition floating toolbars earlier To recreate: - Go to the advanced search form - scrolldown to position the toolbar on top of the window - scrollup https://screenshots.firefox.com/NnkFg3iOXqLPxfkd/pro.kohadev.org The toolbar should have been repositioned earlier Test plan: Edit a patron - scrolldown - scrollup - unfold the form in the header (tab "Search patrons", link "[+]") - scrolldown - scrollup Advanced search scrolldown scrollup You should notice the difference with and without this patch Signed-off-by: Pierre-Luc Lapointe Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens (cherry picked from commit 68e735b10151d7b70187fa7f9d4ecb2b94b34e6a) Signed-off-by: Martin Renvoize --- .../lib/jquery/plugins/jquery.fixFloat.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.fixFloat.js b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.fixFloat.js index 36c99b0c0a..74633e7877 100644 --- a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.fixFloat.js +++ b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.fixFloat.js @@ -8,11 +8,17 @@ var tbh = $(this); var defaults = { enabled: true, - originalOffset: tbh.position().top + originalOffset: tbh.offset().top, + originalPosition: tbh.position().top, }; var originalOffset = typeof options.originalOffset === 'undefined' ? defaults.originalOffset : options.originalOffset; + + var originalPosition = typeof options.originalPosition === 'undefined' + ? defaults.originalPosition + : options.originalPosition; + options = $.extend(defaults, options); if (tbh.css('position') !== 'absolute') { @@ -34,14 +40,16 @@ } tbh.css({ 'position': 'absolute', - 'top': originalOffset + 'top': originalPosition, }); } if (options.enabled) { $(window).scroll(function () { var offsetTop = tbh.offset().top; + var s = parseInt($(window).scrollTop(), 10); + var fixMe = (s > offsetTop); var repositionMe = (s < originalOffset); if (fixMe) { @@ -55,7 +63,7 @@ if (repositionMe) { tbh.css({ 'position': 'absolute', - 'top': originalOffset, + 'top': originalPosition, 'z-index': '1' }); tbh.removeClass("floating"); -- 2.39.5