JSFiddle - React, Tailwind, and code Playground
by nakhli
CSS
(function($) {
$.fn.extend({
sticky: function() {
var header = $(this),
origTop = header.offset().top,
content = header.add("#main");
$(window).scroll(function(e) {
if ($(this).scrollTop() > origTop) {
content.addClass("sticky");
} else if ($(this).scrollTop() < origTop) {
content.removeClass("sticky");
}
});
}
});
$(function() {
$('#summary').sticky();
});
}(jQuery));