Last active
February 27, 2018 16:29
-
-
Save stuartphilp/a8e3f989c1d0364b876db7b45bf745a1 to your computer and use it in GitHub Desktop.
Fixed Position Bugzilla Bug Titles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name ScrollingBugTitlez | |
// @description Pins the bug title header and other useful context so it's always visible when scrolling longer bugs | |
// @include https://bugzilla.mozilla.org/show_bug.cgi?id=* | |
// @author Stuart Philp | |
// ==/UserScript== | |
/* | |
Any copyright is dedicated to the Public Domain. | |
http://creativecommons.org/licenses/publicdomain/ | |
*/ | |
var bugzillaBody = document.querySelector("#bugzilla-body"); | |
var elementPosition = document.querySelector("section.module"); | |
bugzillaBody.addEventListener('scroll', function() { | |
var rect = elementPosition.getBoundingClientRect(); | |
if (bugzillaBody.scrollTop > rect.top) { | |
elementPosition.style.position = "fixed"; | |
elementPosition.style.width = "100%"; | |
elementPosition.style.left = 0; | |
elementPosition.style.top = '44px'; | |
} else { | |
elementPosition.style.position = "static"; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment