Skip to content

Commit

Permalink
sticky demo
Browse files Browse the repository at this point in the history
  • Loading branch information
smashercosmo committed Jul 1, 2013
1 parent e73ef4b commit 460e41c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions sticky/main.js
@@ -1,5 +1,16 @@
$(function(){

window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(/* function */ callback, /* DOMElement */ element){
window.setTimeout(callback, 1000 / 60);
};
})();

var $mainNav = $('.main-nav'),
sticked = false;

Expand All @@ -22,12 +33,12 @@ $(function(){
} else if (scrollTop < 100 && sticked) {
sticked = false;
$mainNav.css({ opacity: 1 });
$clonedNav.css({ opacity: 0 });
$clonedNav.css({ opacity: 0 });
}
}

scroller();

window.addEventListener('scroll', scroller, false);
window.addEventListener('touchmove', scroller, false);

});

0 comments on commit 460e41c

Please sign in to comment.