jQuery Smooth Div Scroll by Thomas Kahn

Back to index

Altering options after initialization

A really nice thing about basing the plugin on the jQuery UI widget factory is that it supports altering options after the plugin has initialized (altering options during runtime). If you want to alter an option after the plugin has loaded, it looks like this:


$("#makeMeScrollable").smoothDivScroll("option","autoScrollDirection","endlessLoopRight");

Looking at the syntax in the example above, the three parameters you supply are these:

  1. "option" - tells the plugin that you want to alter an option.
  2. "autoScrollDirection" - the name of the option that you want to alter, in this case the auto scroll direction.
  3. "endlessLoopRight" - the value you want to set for this option, in this case "endlessLoopRight".

If you don't want to alter the option - just get its value, you just leave out the last parameter, like this:


var currentDirection = $("#makeMeScrollable").smoothDivScroll("option","autoScrollDirection");

Altering some of the options won't do anything simply because it would be odd or unpractical to change them at runtime, for example changing CSS class of the scroller elements using the options scrollingHotSpotLeftClass, scrollingHotSpotRightClass, scrollableAreaClass or scrollWrapperClass. But all(?) the options that I've identified as relevant and useful can be altered while the plugin is running, for example the auto scrolling direction, the intervals and steps of the different scrolling methods and so on.

If you find an option that you think you should be able to alter while the plugin is running, submit an issue at the GitHub page for Smooth Div Scroll and I'll take a look at it.

Back to index