3

I'm using Angular plugin called duScroll (https://github.com/oblador/angular-scroll/) for scrolling when a href is clicked. All the sections are within a container with height of 500px called 'scroll-container'. But the scroll is not happening.

I was able to get it to atleast scroll by changing a line in duScroll.js

proto.scrollToElement = function() {...
...
  return angular.element(document.querySelector('.scroll-container')).scrollTo(0, top-45, duration, easing);
}  

But still the scroll is inconsistent and does not work properly. Where am I going wrong ?

Plnkr : http://plnkr.co/edit/UVh4cjCdMuD9kBMgTgJB?p=preview

2 Answers 2

1

You'd be better off using the directives du-smooth-scroll and du-scroll-container outlined in the documentation.

In your case something like this would work:

<nav du-scroll-container="scroll-container">
  <ul>
    <li><a du-smooth-scroll href="#section-1" >Section 1</a></li>
    …
  </ul>
</nav>
<div id="scroll-container" class="scroll-container">
  …
</div>
Sign up to request clarification or add additional context in comments.

Comments

0

I have the same problem, and I have narrowed it down to setting the height causing the problem. I suspect the listeners get bombed, and so the tab clicks never occur after setting the height. In my case, commenting out the JQuery line setting the height makes it work, but that's not an option for me.

Do you have a better solution?

By the way, using du-scroll-container doesn't work in my case either. I'm not sure why. Here's my code:

 ...
    <nav du-scroll-container="scrollContainer">
                <ul class="nav nav-pills">
                    <li><a du-smooth-scroll="current" du-scrollspy>Current</a></li>
                    <li><a du-smooth-scroll="forecast" du-scrollspy>Forecast</a></li>
                    <li ng-if="launch.webcams"><a href="#webcams" du-smooth-scroll du-scrollspy>Webcams</a></li>
                    <li><a href="#details" du-smooth-scroll du-scrollspy>Details</a></li>
                </ul>
            </nav>
        </div>

            <div id="scrollContainer">
<section id="current">
    ...

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.