Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
143
rated 0 times [  150] [ 7]  / answers: 1 / hits: 54525  / 10 Years ago, sat, october 11, 2014, 12:00:00

I'm looking to implement something similar to this in an AngularJS directive:


https://github.com/geniuscarrier/scrollToTop/blob/master/jquery.scrollToTop.js


It's fairly straightforward, when you are not at the top of the page it will fade in a button to scroll to the top:


$(window).scroll(function() {
if ($(this).scrollTop() > 100) {
$this.fadeIn();
} else {
$this.fadeOut();
}
});

However I'm having a hard time finding how to get the current scroll location in Angular. I'd rather not have to use jQuery just for this single thing.


More From » angularjs

 Answers
28
$window.pageYOffset


This is property from service $window


[#69158] Thursday, October 9, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
carolinabritneyp

Total Points: 75
Total Questions: 102
Total Answers: 105

Location: Armenia
Member since Fri, Apr 16, 2021
3 Years ago
;