thisissoon / angular-scrollspy

A simple lightweight library for Angular which automatically updates links to indicate the currently active section in the viewport
MIT License
35 stars 15 forks source link

Threshold setting #18

Closed moniuch closed 5 years ago

moniuch commented 5 years ago

Please provide threshold parameter/input (on the snScrollSpy directive?), as if answering the question: "what is the threshold value to consider an element as active?"

In my use case I would see two types of units (for both height and width) that I would like to express the threshold:

There should probably also be a parameter to specify whether the calculation should include/exclude margins/padding.

In the below scenario (we see a fixed, semi-transparent navbar above the green line)

chrome_2019-01-09_21-03-56

the content is scrolled to the very bottom (ie. bottom of last section, Section 4), and as you see, the link for that section is still not activated. With the proposed feature, if we specified that 60% of the height is enough to consider an element active, the link would get highlighted, which would correspond with the intuitive perception.

edoparearyee commented 5 years ago

Closing as it's a dup of #1