Cheshire Cheshire - 1 year ago 97
jQuery Question

jQuery - User function into a plugin

I'm making a little plugin. This is a full page plugin, once you scroll, it scrolls the whole view to the next one.

The thing is, I would like that give the user the possibility to add a function once the page has finished scrolling to the section.

Working fiddle (trying to comment the code for basic functionalities):

I was trying to override the onLoad property:

var settings = $.extend({
anchors: [],
showHistory: true,
section: "section",
easing: "easeInOutQuart",
speed: 1000,
onLoad: function() {}
}, opts);

With this:

$(document).ready(function() {
anchors: ["first", "second", "third"],
showHistory: true,
speed: 500,
onLoad: function() {

But it clearly doesn't works that way.

Any help with this?

Answer Source

You just need to call it as a function. Instead of settings.onload you run it as settings.onload() and it should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download