I don’t understand how to update a fucntion’s initial parameters once they’ve been set.
I’m using a plugin called serialScroll. The plugin scrolls to items that are indicated in the initial $(elem).serialScroll({//…}) setup.
What i want to do is redefine the name of that item as the user interacts with the page.
I have another variable which is successfully picking up information as the user scrolls around, that much i have.
All i want to do is make serialScroll({)} update it’s “item:_” field accordingly with that variable.
Here is the serialScroll code:
var nextClass = ".fig4";
// this is being changed to .figN depending on the users
// scrolling position in the browser/viewport (successfully).
// For proof of communication purposes I forced nextClass
// here to equal .fig4 to see if the two are at lest talking to
// each other, which they are... but now how do i update "items:"
// below to reflect the change in the "nextClass" variable?
$('html').serialScroll({
target:'body',
items: nextClass,
next:'#nextImage',
axis:'y',
duration:700,
force:true,
});
What is happening here is that when .serialScroll is initialized, it gets the value of nextClass once, and that is the value it uses.
One of two things would need to happen. Either you modify the plugin to use a global variable (not terrificly ideal, but it works), or every time nextClass changes, you need to reinitialize .serialScroll.