All samples are using Ink.requireModules, please read how to use it at Ink.requireModules section

Ink.UI.Spy class

Spy is an UI component which tells the user which section is currently visible. Spy can be used to highlight a menu item for the section which is visible to the user. You need two things: A menu element (which contains your links inside li tags), and an element containing your section's content. The links must be inside li tags. These will get the 'active' class, to signal which item is currently visible. In your CSS you need to add styling for this class. To use Ink.UI.Spy for more than one section, loop through your sections (as you see in the sample below), or just load autoload.js and set add the data-spy="true" attribute to your sections. The currently visible element's corresponding link in the menu gets the 'visible' class added to it.

Methods
Method name Description
new Spy(selector, [options]) Constructor

new Ink.UI.Spy(selector, [options])

Accepts

  • selector

    The spied element
  • options

    Options
  • options.target

    Target menu where the spy will highlight the right option.
  • options.margin

    0A margin from the top of the screen. Use this if you have a `position:fixed` top bar on your site.

Highlight menu items as the user scrolls (used together with Sticky so that you can see the menu)

Demo

Water

You think water moves fast? You should see ice. It moves like it has a mind. Like it knows it killed the world once and got a taste for murder. After the avalanche, it took us a week to climb out. Now, I don't know exactly when we turned on each other, but I know that seven of us survived the slide... and only five made it out.

Now we took an oath, that I'm breaking now. We said we'd say it was the snow that killed the other two, but it wasn't. Nature is lethal but it doesn't hold a candle to man.

Bones

Your bones don't break, mine do. That's clear. Your cells react to bacteria and viruses differently than mine. You don't get sick, I do. That's also clear. But for some reason, you and I react the exact same way to water. We swallow it too fast, we choke. We get some in our lungs, we drown. However unreal it may seem, we are connected, you and I. We're on the same curve, just on opposite ends.

Pilot

Well, the way they make shows is, they make one show. That show's called a pilot. Then they show that show to the people who make shows, and on the strength of that one show they decide if they're going to make more shows. Some pilots get picked and become television programs. Some don't, become nothing. She starred in one of the ones that became nothing.

Menu won't go below this point

Code

<div class="ink-grid">
    <div class="column-group gutters">
        <div class="all-25">
            <nav class="ink-navigation" id="my-menu">
                <ul class="menu vertical black">
                    <li><a href="#my-section-1">Water</a></li>
                    <li><a href="#my-section-2">Bones</a></li>
                    <li><a href="#my-section-3">Pilot</a></li>
                </ul>
            </nav>
        </div>
        <div class="all-75 my-sections">
            <section id="my-section-1">
                <h2>Water</h2>
                <p>
                    You think water moves fast? You should see ice. It moves like it has a mind. Like it knows it killed the world once and got a taste for murder. After the avalanche, it took us a week to climb out. Now, I don't know exactly when we turned on each other, but I know that seven of us survived the slide... and only five made it out. 
                </p>
                <p>Now we took an oath, that I'm breaking now. We said we'd say it was the snow that killed the other two, but it wasn't. Nature is lethal but it doesn't hold a candle to man.</p>
            </section>
            <section id="my-section-2">
                <h2>Bones</h2>
                <p>
                    Your bones don't break, mine do. That's clear. Your cells react to bacteria and viruses differently than mine. You don't get sick, I do. That's also clear. But for some reason, you and I react the exact same way to water. We swallow it too fast, we choke. We get some in our lungs, we drown. However unreal it may seem, we are connected, you and I. We're on the same curve, just on opposite ends.

                </p>
            </section>
            <section id="my-section-3">
                <h2>Pilot</h2>
                <p>
                    Well, the way they make shows is, they make one show. That show's called a pilot. Then they show that show to the people who make shows, and on the strength of that one show they decide if they're going to make more shows. Some pilots get picked and become television programs. Some don't, become nothing. She starred in one of the ones that became nothing.
                </p>
            </section>
        </div>
    </div>
    <p id="below-demo"><span class="ink-label black">Menu won't go below this point</span></p>
</div>

<script>
    // If you included `autoload.js` in your page, you can just
    // follow the example below
    Ink.requireModules( ['Ink.Dom.Selector_1','Ink.UI.Spy_1','Ink.UI.Sticky_1'], function( Selector, Spy, Sticky ){
        var myMenu = Ink.i('my-menu');
        var sections = Ink.ss('.my-sections section');

        for (var i = 0, len = sections.length; i < len; i++) {
            new Spy(sections[i], { target: myMenu });
        }

        new Sticky('#my-menu', { offsetTop: 60, bottomElement: '#below-demo' })
    });
</script>

Code (With autoload.js)

<div class="column-group">
    <div class="left-column all-25">
        <nav class="ink-navigation ink-sticky" id="my-menu">
            <ul class="menu vertical black">
                <li><a href="#my-section-1">Water</a></li>
                <li><a href="#my-section-2">Bones</a></li>
                <li><a href="#my-section-3">Pilot</a></li>
            </ul>
        </nav>
    </div>
    <div class="all-75 my-sections">
        <section id="my-section-1" data-spy="true" data-target="#my-menu">
            <h2>Water</h2>
            <p>...</p>
        </section>
        <section id="my-section-2" data-spy="true" data-target="#my-menu">
            <h2>Bones</h2>
            <p>...</p>
        </section>
        <section id="my-section-3" data-spy="true" data-target="#my-menu">
            <h2>Pilot</h2>
            <p>...</p>
        </section>
    </div>
</div>