Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mjinayan80/616f755da8b6907a294d6f92755d5e1c to your computer and use it in GitHub Desktop.
Save mjinayan80/616f755da8b6907a294d6f92755d5e1c to your computer and use it in GitHub Desktop.
Jquery All Source
$('.count').each(function () {
$(this).prop('Counter',0).animate({
Counter: $(this).text()
}, {
duration: 4000,
easing: 'swing',
step: function (now) {
$(this).text(Math.ceil(now));
}
});
});
// Check the initial Poistion of the Sticky Header
var stickyHeaderTop = $('#stickyheader').offset().top;
$(window).scroll(function(){
if( $(window).scrollTop() > stickyHeaderTop ) {
$('#stickyheader').css({position: 'fixed', top: '0px'});
$('#stickyalias').css('display', 'block');
$('#stickyheader').addClass('fix-top');
} else {
$('#stickyheader').css({position: 'static', top: '0px'});
$('#stickyalias').css('display', 'none');
$('#stickyheader').removeClass('fix-top');
}
});
//Nav menu active class change
var lastId
, topMenu = $(".menu")
, topMenuHeight = topMenu.outerHeight() + 15
,menuItems = topMenu.find("a")
,scrollItems = menuItems.map(function () {
var item = $($(this).attr("href"));
if (item.length) {
return item;
}
});
// Bind to scroll
$(window).scroll(function () {
var fromTop = $(this).scrollTop() + topMenuHeight;
var cur = scrollItems.map(function () {
if ($(this).offset().top < fromTop) return this;
});
cur = cur[cur.length - 1];
var id = cur && cur.length ? cur[0].id : "";
if (lastId !== id) {
lastId = id;
menuItems.parent().removeClass("active").end().filter("[href='#" + id + "']").parent().addClass("active");
}
});
<html>
<head>
<style type="text/css">
/*
Preloader
*/
body.preloader-active {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 999999999;
overflow: hidden;
}
.preloader {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
background: #fff;
z-index: 9999999999;
}
.preloader-spinner {
background: url(../img/preloader.gif) no-repeat center center;
width: 100px;
height: 100px;
left: 50%;
top: 50%;
margin-top: -50px;
margin-left: -50px;
position: absolute;
}
</style>
</head>
<body>
<div class="preloader">
<!--Background Image Add in preloader-spinner Class -->
<div class="preloader-spinner"></div>
</div>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
/***
Preloader
***/
$('body').addClass('preloader-active');
$(window).on('load', function() {
$('.preloader').fadeOut();
$('.preloader-spinner').delay(350).fadeOut('slow');
$('body').removeClass('preloader-active');
});
</script>
</body>
</html>
function responsiveMenu($width){
if ($(window).width() < $width) {
$("#menu").hide();
}else {
$("#menu").show();
}
$('.menu-button').on('click' , function(){
$("#menu").slideToggle(500);
return false;
})
}
responsiveMenu(767);
function scrollToTop($topClass){
var top_0 = {scrollTop:0};
var topClass = $($topClass);
topClass.on("click" , function(e){
$("html,body").animate(top_0,1000);
return false;
});
$(window).scroll(function(){
if($(this).scrollTop() > 400) {
topClass.fadeIn(500);
}
else {
topClass.fadeOut(500);
}
});
}
scrollToTop('.scrolltotop i');
$('.menu a[href*="#"]:not([href="#"])').on("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;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment