I am new to jQuery and I do use a lot of jQuery plugins. I recently started learning parallax and came across this great plugin, scrollr.js, it's fantastic.
I have a question about the initialization of this plugin:
Most plugins I use, I initialize it like so:
$(element).pluginname({parameters if any});
but why does scrollr have this really weird initialization, like below?
skrollr.init({
forceHeight: false
});
before using this plugin, I did read quite a few articles online that did mention, this plugin syntax will take some getting used to. But nowhere could I find a justification for such initialization syntax.
The true answer is "because the creator wanted it to be that way".
Now, of course, the usual plugins operate on specific elements in isolation while the skrollr plugin requires some prior setup, for example event listeners on device orientation change, etc. The author decided to make the initialization step explicit and thus you need to write it that way.
You can take a look at the source code for more information.