Skip to content

Instantly share code, notes, and snippets.

@PsyGik
Created May 11, 2015 12:49
Show Gist options
  • Save PsyGik/41d6f79331b23c892605 to your computer and use it in GitHub Desktop.
Save PsyGik/41d6f79331b23c892605 to your computer and use it in GitHub Desktop.
Header that shrinks on page scroll
#header_nav {
width:100%;
background-color:#666;
position:fixed;
top:0;
left:0;
-webkit-transition:0.5s linear all;
-moz-transition:0.5s linear all;
-o-transition:0.5s linear all;
transition:0.5s linear all;
}
.big {
height:100px;
}
.small {
height:40px;
}
function myCtrl($scope, $window) {
$scope.navClass = 'big';
angular.element($window).bind(
"scroll", function() {
console.log(window.pageYOffset);
if(window.pageYOffset > 0) {
$scope.navClass = 'small';
} else {
$scope.navClass = 'big';
}
$scope.$apply();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment