From the documentation for jquery.cycle, you are supposed to put functions in with just the function name (onBefore, onAfter in the example below:

$('#s5').cycle({ 
    fx:     'scrollLeft', 
    timeout: 5000, 
    before:  onBefore, 
    after:   onAfter 
 });

However, when adding the same behavior in the advanced options screen in views slideshow, the functions have to be appended with parenthesis, like so

onBefore()

I believe this boils down to how these functions are being called:

(line 199 of views_slideshow_cycle.js)

 case "before":
var beforeValue = advancedOptions[option];
beforeValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(beforeValue);
// transition callback (scope set to element to be shown): function(currSlideElement, nextSlideElement, options, forwardFlag)
settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) {
eval(beforeValue);
}

eval(beforeValue) returns "function()" when called without a parentheses (like eval(onBefore), but it actually invokes the function if you call eval(onBefore()).

Hope this makes sense. took me an hour or so scratching my head as to why this wasn't workign as exppected.

Comments

NickWilde’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

hmmm I can see that as potentially a bug, certainly an inconsistency. However it has been that way for years so for 7.x-3.x I don't want to change that as it could easily break thousands of sites. Some slightly enhanced documentation would be the best thing to do I think, thanks for the report/detailed information.