Last active
August 29, 2015 14:05
-
-
Save hobbes3/f118b35e20fef223dda1 to your computer and use it in GitHub Desktop.
sticky floating div inputs
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
#sticky.stick { | |
position: fixed; | |
top: 0; | |
z-index: 1000; /* Splunk modals are 1050 */ | |
margin-top: 10px; | |
} |
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
require([ | |
'jquery', | |
'underscore', | |
'splunkjs/mvc', | |
'splunkjs/mvc/simplexml/ready!' | |
], function( | |
$, | |
_, | |
mvc | |
) { | |
function sticky_relocate() { | |
var window_top = $(window).scrollTop(); | |
var div_top = $('#sticky-anchor').offset().top; | |
if (window_top > div_top) { | |
//$('.splunk-choice-input').css('padding-bottom', '0px'); | |
//$('.fieldset .element').css('padding-bottom', '0px'); | |
$('#sticky').addClass('stick'); | |
} else { | |
//$('.splunk-choice-input').css('padding-bottom', '15px'); | |
//$('.fieldset .element').css('padding-bottom', '10px'); | |
$('#sticky').removeClass('stick'); | |
} | |
} | |
$(".fieldset:first").attr('id', 'sticky').before('<div id="sticky-anchor"></div>'); | |
$(window).scroll(sticky_relocate); | |
sticky_relocate(); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment