$( document ).ready(function() { // Handler for .ready() called. setMenuImageStyle(); }); $(window).resize(function() { setMenuImageStyle(); }); function setMenuImageStyle() { var mnuHeight = parseInt($("#sideMenu.active").height()); var mobile = $(".mobileNavItem").css("display"); if (isNaN(mnuHeight) == true) { mnuHeight=0; } else { mnuHeight=mnuHeight -10;} if (mobile!=="none") {mnuHeight=0; } // alert("mnuHeight: " + mnuHeight); $(".lineImg").css("padding-top", mnuHeight + "px"); } /* Smooth Scrolling to Anchors */ $(function() { $('a[href*="#"]:not([href="#"])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html, body').animate({ scrollTop: target.offset().top }, 1000); return false; } } }); }); /* Dynamischer Top-Button je nach Scrolling */ $(document).ready(function () { var dstElement = $("#bottomElement"); var maxElement = $(".containerFOOTER_top"); var dstHoehe = $(dstElement).position().top + $(dstElement).outerHeight(true) - $(window).height(); var maxHoehe = $(maxElement).position().top - 90; $(window).scroll(function () { var btnHoehe = $("#goTopNow").position().top; console.log ("ButtonTop: " + btnHoehe + " plus Scroll: " + (btnHoehe + $(this).scrollTop())); console.log ("ScrollTop: " + $(this).scrollTop() + " -> maxHoehe: " + maxHoehe + " -> Bottom: " + dstHoehe + " --> Window: " + $(window).height() ); // $("#goTopNow").removeClass("sticky"); /* Stick to Bottom (vor Footer) */ if ( (btnHoehe + $(this).scrollTop()) > maxHoehe) { $("#goTopNow").addClass("sticky"); } // if (($(this).scrollTop() + dstHoehe +200) < btnHoehe ) { $("#goTopNow").removeClass("sticky"); } if (dstHoehe < 0) { // Nur wenn mehr als Seitenhöhe return false; } if (dstHoehe > $(window).height() - 200 ) { // Bei langer Seite ab Seitenhöhe anzeigen dstHoehe = $(window).height() -200 ; if (($(this).scrollTop() + dstHoehe +200) < btnHoehe ) { $("#goTopNow").removeClass("sticky"); } } else { if (($(this).scrollTop() ) < dstHoehe ) { $("#goTopNow").removeClass("sticky"); } } // Ein- und ausblenden if ($(this).scrollTop() > dstHoehe) { $('#goTopNow').fadeIn(); } else { $('#goTopNow').fadeOut(); } }); });