All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gwt.material.design.addins.client.subheader.resources.js.subheader.min.js Maven / Gradle / Ivy

There is a newer version: 2.8.3
Show newest version
function initSubheader(stickyElem, containerElem) {
    jQuery(document).ready(function(){
        var newStickies = new stickyTitles(stickyElem, containerElem);
        newStickies.load();
        $(containerElem).on("scroll", function() {
            newStickies.scroll();
        });
    });
}

function stickyTitles(stickyElem, containerElem) {
    var stickies = jQuery(stickyElem);
    var container = jQuery(containerElem);
    container.addClass("subheader-container");

    /** Added top holder component **/
    var topHolder = document.createElement("div");
    $(topHolder).addClass("top_holder");
    container.prepend(topHolder);
    this.load = function() {


        stickies.each(function(){

            var thisSticky = jQuery(this).wrap('
'); thisSticky.parent().height(thisSticky.outerHeight()); jQuery.data(thisSticky[0], 'pos', thisSticky.position().top); }); } this.scroll = function() { $(topHolder).css('top', container.scrollTop()); $(topHolder).addClass("z-depth-1"); stickies.each(function(i){ var thisSticky = jQuery(this), nextSticky = stickies.eq(i+1), prevSticky = stickies.eq(i-1), pos = jQuery.data(thisSticky[0], 'pos'); if(container.scrollTop() == 0){ $(topHolder).hide(); }else{ $(topHolder).show(); } if (pos <= container.scrollTop()) { $(topHolder).html(''); thisSticky.clone().appendTo($(topHolder)); } else { thisSticky.removeAttr('style').show(); if (prevSticky.length > 0 && container.offset().top <= jQuery.data(thisSticky[0], 'pos') - prevSticky.outerHeight()) { prevSticky.removeClass("absolute").removeAttr("style"); } } }); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy