1

I'm using Angular Scroll and once you hit a certain page I fire a function to scroll to an id. I'm getting the following error on the code below:

TypeError: $document.scrollToElement is not a function

initHelp();

function initHelp() {
    console.log('initHelp');
    $document.scrollToElement('#chart-help', 500).then(function() {
        console && console.log('You just scrolled to chart-help!');
    });
}

The docs from angular-scroll

.scrollTo( element [, offset, [, duration [, easing ] ] ] )

Alias of .scrollToElement.

.scrollToElement( element [, offset, [, duration [, easing ] ] ] )
1
  • No, didn't realize this required jquery... Commented Jul 14, 2015 at 14:42

1 Answer 1

1

Figured it out:

var chartHelp = angular.element(document.getElementById('chart-help'));

$document.scrollToElement(chartHelp, 30, 500).then(function() {
    console && console.log('You just scrolled to chart-help!');
});

Also from their docs, I was missing the offset number: $document.scrollToElement(someElement, offset, duration);

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.