Cart

Scrollspy

The scrollspy component listens to page scrolling and triggers events based on the scroll position. For example, if you scroll down a page and an element appears the first time in the viewport you can trigger a smooth animation to fade in the element.

Data attribute

Description

data-uk-scrollspy="{cls:'MY-CLASS'}"

Applies the class only the first time the element appears in the viewport.

Example

To automatically update the active menu item in a menu depending on the scroll position of your site, just add the data attribute data-uk-scrollspy-nav to any navigation. Each menu item must link to the ID of its corresponding part of the site.

Data attribute

Description

data-uk-scrollspy-nav

Triggers the JavaScript necessary for the functionality of the scrollspy nav.

data-uk-scrollspy-nav="{closest:'MY-SELECTOR'}"

Looks for the closest element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.

data-uk-scrollspy-nav="{smoothscroll:true}"

Applies the Smooth scroll component when skipping between different sections of the site.

data-uk-scrollspy-nav="{cls:'MY-CLASS'}"

By default ScrollspyNav toggles the uk-active class. Use the cls option to use your own class name.

About our company:

Company Address is an internationally recognised provider of virtual and mail forwarding address services to small and growing businesses.

Established a few years ago, we are proud to provide our services to over 1500 customers in the UK and overseas. Our customers include small businesses, startups, website owners, home-based businesses, growing enterprises and international businesses moving market.