Last active
August 29, 2015 14:14
-
-
Save goldhand/9ef6ffd240d7acf880ec to your computer and use it in GitHub Desktop.
messing with scrolling in angularjs
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
$rootScope.scrollLevel = { | |
'one': false, | |
'two': false, | |
}; | |
$rootScope.scrollY = window.pageYOffset; | |
$rootScope.scrollingDown = false; | |
$rootScope.scrollingUp = false | |
window.onscroll = function () { | |
if($rootScope.scrollY>window.pageYOffset){ | |
$rootScope.scrollingDown = false; | |
$rootScope.scrollingUp = true; | |
}; | |
if($rootScope.scrollY<window.pageYOffset){ | |
$rootScope.scrollingDown = true; | |
$rootScope.scrollingUp = false; | |
}; | |
$rootScope.scrollY = window.pageYOffset; | |
// any $scope variable updates | |
if($rootScope.scrollY<=64) { | |
$rootScope.scrollLevel.one=false; | |
}; | |
if($rootScope.scrollY>64) { | |
$rootScope.scrollLevel.one=true; | |
}; | |
if($rootScope.scrollY>128) { | |
$rootScope.scrollLevel.two=true; | |
}; | |
if($rootScope.scrollY<=128) { | |
$rootScope.scrollLevel.two=false; | |
}; | |
$scope.$digest(); | |
}; | |
$scope.$on('$destroy', function() { | |
window.onscroll = null; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment