Created
November 19, 2015 13:58
-
-
Save mjpitz/e9148cb0df9294ec0d0e to your computer and use it in GitHub Desktop.
Same as the js file, but as a bookmarklet
This file contains 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
javascript:(function() {var $ = function(str) {return document.querySelector(str);};var win = window;var doc = document.documentElement;var mast = $('#js-repo-pjax-container .pagehead');var mastTop = mast.offsetTop;var adjustedMargin = mast.offsetHeight;var currentMastAttributes = mast.getAttribute('style');var newMastAttributes = [currentMastAttributes,'position: fixed;','z-index: 10;','top: 0;','left: 0;','right: 0;'].join('');var content = $('#js-repo-pjax-container .repo-container');var currentContentAttributes = content.getAttribute('style');var newContentAttributes = [currentContentAttributes,'margin-top: ' + adjustedMargin + 'px;'].join('');var toggle = false;document.addEventListener('scroll', function() {var scrollTop = (win.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);if (scrollTop > mastTop) {content.setAttribute('style', newContentAttributes);mast.setAttribute('style', newMastAttributes);toggle = true;setTimeout(function() {toggle = false}, 100);} else if (!toggle) {content.setAttribute('style', currentContentAttributes);mast.setAttribute('style', currentMastAttributes);}});}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment