Created
May 11, 2015 12:49
-
-
Save PsyGik/41d6f79331b23c892605 to your computer and use it in GitHub Desktop.
Header that shrinks on page scroll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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