How to use the scroll-js.scrollTo function in scroll-js

To help you get started, we’ve selected a few scroll-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pattern-lab / patternlab-node / packages / uikit-workshop / src / scripts / components / modal-viewer.js View on Github external
slideToAnnotation(pos) {
    // remove active class
    const els = document.querySelectorAll('.pl-js-annotations li');
    for (let i = 0; i < els.length; ++i) {
      els[i].classList.remove('pl-is-active');
    }

    const patternInfoElem = document.querySelector('.pl-js-pattern-info');
    // const scroll = new Scroll(patternInfoElem);

    // add active class to called element and scroll to it
    for (let i = 0; i < els.length; ++i) {
      if (i + 1 === pos) {
        els[i].classList.add('pl-is-active');

        scrollTo(patternInfoElem, document.body, {
          top: els[i].offsetTop - 14,
          behavior: 'smooth',
        }).then(function() {
          // console.log('finished scrolling');
        });
      }
    }
  },

scroll-js

Light cross-browser scroller that uses native javascript

MIT
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis

Popular scroll-js functions