$(window).on("scroll", function(e) { var scrollTop = $(window).scrollTop(); if (scrollTop > 0) { $("header").addClass("scrolled"); } else { $("header").removeClass("scrolled"); } }); var $headerHeight = $(".header").innerHeight(); $(document).ready(function() { $("#mm-my-menu").css({ height: `calc(100% - ${$headerHeight}px)` }); var scrollTop = $(window).scrollTop(); if (scrollTop > 0) { $("header").addClass("scrolled"); } else { $("header").removeClass("scrolled"); } }); var $headerScrollHeight = $(".header").height(); $(window).scroll(function() { if ($(this).scrollTop() === 0) { $("#mm-my-menu").css({ height: `calc(100% - ${$headerHeight}px)` }); } else { $("#mm-my-menu").css({ height: `calc(100% - ${$headerScrollHeight}px)` }); } }); // Odliczanie; $.fn.isOnScreen = function() { var win = $(window); var viewport = { top: win.scrollTop(), left: win.scrollLeft() }; viewport.right = viewport.left + win.width(); viewport.bottom = viewport.top + win.height(); var bounds = this.offset(); bounds.right = bounds.left + this.outerWidth(); bounds.bottom = bounds.top + this.outerHeight(); return !( viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom ); }; $(document).ready(function() { $(window).scroll(function() { if ($('#counters').length && $("#counters").isOnScreen()) { counter(); } }); }); function counter() { $(".counter").each(function() { var $this = $(this), countTo = $this.attr("data-count"); $({ countNum: $this.text() }).animate( { countNum: countTo }, { duration: 800, easing: "linear", step: function() { $this.text(Math.floor(this.countNum)); }, complete: function() { $this.text(this.countNum); } } ); }); } //insta feed//