Skip to content

Instantly share code, notes, and snippets.

@hobbes3
Last active August 29, 2015 14:05
Show Gist options
  • Save hobbes3/f118b35e20fef223dda1 to your computer and use it in GitHub Desktop.
Save hobbes3/f118b35e20fef223dda1 to your computer and use it in GitHub Desktop.
sticky floating div inputs
#sticky.stick {
position: fixed;
top: 0;
z-index: 1000; /* Splunk modals are 1050 */
margin-top: 10px;
}
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