Highlight elements as you scroll
All samples are using
Ink.requireModules, please read how to use it at Ink.requireModules section
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.
|new Spy(selector, [options])||Constructor|
selectorThe spied element
options.targetTarget menu where the spy will highlight the right option.
options.margin0A 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)
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.
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.
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 (With autoload.js)