Skip to content

Instantly share code, notes, and snippets.

@mlauren
Last active August 29, 2015 14:05
Show Gist options
  • Save mlauren/3e48f9015a10354d2fbf to your computer and use it in GitHub Desktop.
Save mlauren/3e48f9015a10354d2fbf to your computer and use it in GitHub Desktop.
messing w directives
poopoo.directive('fixedHeader', function() {
return {
// Restrict it to be an attribute in this case
restrict: 'A',
link: function(scope, element, attrs) {
window.scrollmything = function() {
var window = this;
window.elementHeight = element.height();
window.activate();
$(window).on('scroll', this.activate);
$(window).on('resize', this.activate);
};
window.activate = function() {
var scrollTop = $(window).scrollTop();
if( scrollTop > window.elementHeight ) {
window.scrollEnabled();
} else {
window.scrollDisabled();
}
};
window.scrollEnabled = function() {
$(element).addClass('fixed');
};
window.scrollDisabled = function() {
$(element).removeClass('fixed');
};
window.scrollmything();
}
};
});
@mlauren
Copy link
Author

mlauren commented Apr 29, 2015

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment