Angular: CSS styling
http://angularjs.org/
by allcaps
HTML
<div ng-app="myApp" scroll id="page" ng-class="{min:boolChangeClass}">
<header></header>
<section></section>
</div>
CSS
#page {
height: 1000px;
}
header {
height: 100px;
background-color: grey;
}
section {
height: 900px;
background-color: lightgrey;
}
.min section {
background-color: pink;
}
JavaScript
app = angular.module('myApp', []);
app.directive("scroll", function ($window) {
return function(scope, element, attrs) {
angular.element($window).bind("scroll", function() {
console.log(this.pageYOffset);
if (this.pageYOffset >= 100) {
scope.boolChangeClass = true;
console.log('Scrolled below header.');
} else {
scope.boolChangeClass = false;
console.log('Header is in view.');
}
scope.$apply();
});
};
});