The only scrollspy option listed in the documentation is offset. However, the same page has an example with option target. Also the code mention (and use) an option _offset method_. Those two options should be present in the options table.
Technically, offset isn't an event right? So maybe its in the right place?
The target isn't an option鈥攊t's required to make it work. I'd say the docs are correct in this matter, but I'm open to hearing from others if it's confusing.
Ok for target.
But what about the offset method property, who may have value: auto, offset or position? For example:
$("#scrollspy").scrollspy({
offset: 100,
method: "position"
});
As there is no mention of method elsewhere than in the code, it's not clear if this is for some _internal_ use only or this is part of the public API.
I defer to @Johann-S and team on reviewing those bits.
That's right this option is missing in our docs, nice catch @denisname 馃憤
I've been trying to use method as an option, but not sure if i'm doing something wrong or if it's not working properly.
was this ever updated? I didn't see anything in the dev branch and am also having issues with it
I'd like to give this issue a try.
I'm trying to determine how the method values of auto, offset, and position are different from each other so that I can update the documentation to reflect how to use these. I have tried adding and switching between data-method="auto", data-method="offset", and data-method="position" to the HTML code, and also tried adding and switching between method: "auto", method: "offset", and method: "position" to the JavaScript code, but could not really differentiate if anything was changing when I switched the values. The only thing I noted was sometimes using offset in the HTML code seemed to break scrollspy except for the last value in the nav or list.
Could someone help point me in the right direction for this? My apologies if I'm missing something obvious, I'm fairly new to making contributions, but very eager to figure this out.
Hi @unaccomplished,
The option method allow us to know how we should find in which section the spied element is.
auto means we will choose what method suit the best.
offset means we will use the jQuery offset method to get the scroll coordinates
position means we will use the jQuery position method to get the scroll coordinates.
There is one missing option, which is target 馃 we should add a little note about that option too
Hi @Johann-S,
Thank you so much for clarifying the method options. I tried to figure out how target works, but wasn't sure exactly what it does. Do you know?
I have created a pull request to reflect the method options you clarified, and I can update with target as well, once I get some clarification on how that works. Thank you!
The target option allow you to use our ScrollSpy plugin on a specific element, you can see it in action here: https://getbootstrap.com/docs/4.1/components/scrollspy/#example-in-navbar
Thank you @Johann-S! I have pushed an update to my pull request to include target as well.