'use strict';

angular.module("fixIt", [])
	.directive('fixIt', ["$q", "$window", function($q, $window){
		return{
			restrict: 'AE',
			link: function(scope, element, attrs){
				var top = element[0].offsetTop;
				angular.element($window).bind('scroll', function(){
                	if(this.pageYOffset >= top){
                		//angular.element("body").addClass("fixed");
						element.addClass("fixed");
						//$compile(element)(scope);
                	}
                	else{
                		element.removeClass("fixed");
						//$compile(element)(scope);
                	}
            	});
			}
		}
	}]);
