oblador / angular-scroll

Scrollspy, animated scrollTo and scroll events for angular.js
http://oblador.github.io/angular-scroll/
MIT License
1.48k stars 235 forks source link

duScrollspy not working and other strange behaviour #130

Open ux-engineer opened 9 years ago

ux-engineer commented 9 years ago

Hi,

When I added this to my navigation controller to be run before view change:

$document.scrollTop(top, duration).then(function() {
  console && console.log('You just scrolled to the top!');
});

I get console errors:

Error: $document.scrollTop(...).then is not a function
$scope.selectView@https://myapp.loc/pkg/myapp/js/controllers.js:604:3
$parseFunctionCall@https://myapp.loc/pkg/angular/js/angular13.js:12133:15
ngEventHandler/</callback@https://myapp.loc/pkg/angular/js/angular13.js:22518:17
$RootScopeProvider/this.$get</Scope.prototype.$eval@https://myapp.loc/pkg/angular/js/angular13.js:14123:16
$RootScopeProvider/this.$get</Scope.prototype.$apply@https://myapp.loc/pkg/angular/js/angular13.js:14221:18
ngEventHandler/<@https://myapp.loc/pkg/angular/js/angular13.js:22523:17
x.event.dispatch@https://myapp.loc/pkg/jquery/js/jquery.js:5:9453
x.event.add/y.handle@https://myapp.loc/pkg/jquery/js/jquery.js:5:6271

For some reason "du-scrollspy" is not working at all, no errors in console. I have tried in on several different elements, only one at a time and no other directives or functionalities of this library in use. I encountered the above mentioned error when trying other functionality to ensure the library has been properly loaded as it was failing silently.

ux-engineer commented 9 years ago

Aha, changing scrollTop to duScrollTo solved the first issue as mentioned in the doc. But the main problem is open that why du-scrollspy is not doing anything.

oblador commented 9 years ago

Does the demo work? If so, then you're doing something wrong but it's hard for me to tell what without any code. Can you post a plunker?

On Fri, Jul 3, 2015 at 8:29 AM, Janne Kurkinen notifications@github.com wrote:

Aha, chinging scrollTop to duScrollTo solved the first issue as mentioned in the doc. But the main problem is open that why du-scrollspy is not doing anything.

Reply to this email directly or view it on GitHub: https://github.com/oblador/angular-scroll/issues/130#issuecomment-118250061

ux-engineer commented 9 years ago

I would need scrollspy feature for just so simple task that a sub-navigation element would be applied a class / fixed position after it is scrolled over the top. Perhaps this library is overkill for it?

I just tried to strip the demo off all the scrollspy features except one element having du-scrollspy directive applied. No active class was applied then.

oblador commented 8 years ago

du-scrollspy relies on the href attribute to find it's target so if you remove that you need to define it like this instead: du-scrollspy="anchor"

homerjam commented 8 years ago

I found a weird hidden issue in my code that my be relevant to you, mentioned here.

michelem09 commented 8 years ago

@envision @homerjam what AngularJS version do you have? I have the same issue with Angular 1.5.5

homerjam commented 8 years ago

Sorry can't recall what I was using then but certainly pre 1.5.5. Checkout my comment in the other thread - it was down to the component/view/controller being compiled twice for some reason.