Scrollspy

Trigger events and animations while scrolling your page.

Usage

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.
data-uk-scrollspy="{cls:'MY-CLASS', repeat: true}" Applies the class everytime the element appears in the viewport.
data-uk-scrollspy="{cls:'MY-CLASS', delay:600}" Adds a delay in milliseconds to the animation.

Typically, classes from the Animation component are used together with the scrollspy.

Examples

This example uses the repeat: true option. Scroll up and down to see the triggered animations.

Fade

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Scale up

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Scale down

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Slide top

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Slide bottom

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Slide right

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Slide left

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Delay

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Delay

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Delay

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Delay

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Markup

<div data-uk-scrollspy="{cls:'uk-animation-fade'}">...</div>

<div data-uk-scrollspy="{cls:'uk-animation-fade', repeat: true}">...</div>

<div data-uk-scrollspy="{cls:'uk-animation-fade', delay:900}">...</div>

JavaScript options

This is an example of how to set options via attribute:

data-uk-scrollspy="{cls:'uk-animation-fade'}"
Option Possible value Default Description
cls string ‘uk-scrollspy-inview’ Class to add when element is in view
initcls string ‘uk-scrollspy-init-inview’ Class to add when element is in view for first time
topoffset integer 0 Top offset before triggering in view
leftoffset integer 0 Left osset before triggering in view
repeat boolean false Applies the in view class everytime the element appears in the viewport.
delay integer 0 Delay time in ms

Events

You can bind callbacks to following events for custom functionality:

Name Description
uk.scrollspy.init Triggered when the element is initially in the viewport
uk.scrollspy.inview Triggered when the element is in the viewport
uk.scrollspy.outview Triggered when the element leaves the viewport

Example

$('[data-uk-scrollspy]').on('uk.scrollspy.inview', function(){
    // custom code...
});

Scrollspy Nav

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.

Markup

<ul class="uk-nav uk-nav-side" data-uk-scrollspy-nav="{closest:'li', smoothscroll:true}">
    <li><a href="#MY-ID">...</a></li>
    <li><a href="#MY-ID2">...</a></li>
</ul>

<div id="MY-ID">...</div>
<div id="MY-ID2">...</div>

JavaScript options

This is an example of how to set options via attribute:

data-uk-scrollspy-nav="{smoothscroll:true}"
Option Possible value Default Description
cls string ‘uk-active’ Class to add to active element
closest CSS selector false Element selector to aply the active class to
topoffset integer 0 Sroll top-offsset
leftoffset integer 0 Sroll left-offsset
smoothscroll boolean false Scroll animation

Events

Name Parameter Description
init.uk.scrollspy event On scrollspy first init
inview.uk.scrollspy event Element entered view-port
outview.uk.scrollspy event Element left view-port

Testimonials

  • P Dave

    Reliable tenants made being landlord stress free. Besides being professional they are also well versed with nitty-gritties of Landlord tenant issue. As a first time landlord they helped me understand the the importance of choosing a right tenant. I always recommend Reliabletenants to my colleagues & friends.

  • Preet A

    My investment properties keep on changing but Reliabletenants are constant. With them at the helm I go about my work / travel abroad / go on vacations with a complete peace of mind. For all those investors out there, I strongly recommend reliabletenants.ca.

  • Robert Polski

    "You guys are so good! You guys actually exceeded my expectations from a Realtor!"

  • B & J smith

    I am thankful to my friend for recommending reliabletenants.ca and I in turn referred them to everyone I know. The reason is obvious. They are one of the finest, most knowledgeable and most respected agents I have ever met. They provide an excellent service. But don’t just read this, try them out for yourself. You’ll see.”

  • SAAD ABDO

    I want to let you know that we were really happy with reliabletenants.ca for sheltering us from all the unpleasent issues of being a landlord. we would definitely keep you in our mind for our next project

  • A & F Sultan

    "It is our pleasure to express thanks to reliabletenants.ca for giving us peace of mind. I was tired & overwhelmed with various issues arising & was ready to sell my property. I am more than happy to have retained my investment property. I would recommend reliabletenants without any reservations or second thoughts to our friends and family."

  • Odombo P.

    Reliabletenants are reliables themselves – Take it from me. They are looking after Mine & my relatives properties. So far no issues. Hopefully it continues in future too.

  • LE NGUYEN

    Reliabletenants are reliables themselves – Take it from me. They are looking after Mine & my relatives properties. So far no issues. Hopefully it continues in future too.

  • T PIETOWSKI

    I wish I had listened to reliabletenants.ca when they told me to transfer all utility bills to tenant, I didn't follow their advice & had to suffer because of the same. From then on I follow their suggestions to T.

  • Rajiv

    Reliabletenants.ca are a group of good folks. Everyone knows their role which in turn makes things very present for Landlord. Happy:)

Social

Logout