3

I am starting a new project and using Angular Material with AngularJS. I am having trouble to make smooth scrolling work. I am using this smooth scroll library: https://github.com/oblador/angular-scroll

I also try this one: https://github.com/d-oliveros/ngSmoothScroll But none of them work. I make a codepen to demo the problem here:

http://codepen.io/hughred22/pen/XmRpOG/

As you see in my Codepen, if I comment out

document.getElementById('bottom').scrollIntoView(true);

To show scrollIntoView work and it scroll to the div. But smooth scroll won't work for some reason. Please help!

1 Answer 1

2

You should use the proper container to initiate scrolling. Check a fixed fork of your codepen here http://codepen.io/harconst/pen/qOmPVo

Notice that in my codepen, the container is not the whole document anymore.

var someElement = angular.element(document.getElementById('bottom'));
var container   = angular.element(document.getElementById('container'));    
container.scrollTo(someElement,0,1000);   
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.