I'm trying to implement and customize a little the behavior of the jquery tools scrollable plugin. What I want is calling a function just before sliding to the next item, waiting for the function to complete and just then slide to the next item.
I tried out the onBeforeSeek function from the api, but it unfortunately calls my desired function (like f.ex. setTimeout) and doesn't wait for it to finish, it immediately slides to the next item.
Has someone any idea how I can prevent from sliding to the next item until a function is completed? It doesn't have to occur absolutely trough the onBeforeSeek, but it seemed to me ok, because it summarizes the result of several events that trigger prev/next.
Markup:
<section>
<div>
<dl>
<dt>titre 1</dt>
<dd><img src="http://placehold.it/350x150"></dd>
</dl>
<dl>
<dt>titre 2</dt>
<dd><img src="http://placehold.it/350x150"></dd>
</dl>
<dl>
<dt>titre 3</dt>
<dd><img src="http://placehold.it/350x150"></dd>
</dl>
</div>
</section>
<!-- navigation (cubes) -->
<div class="navi"></div>
<br style="clear: both;">
<!-- navigation prev/next -->
<a class="prev browse left">prev</a> | <a class="next browse right">next</a>
JS:
$('section').css('overflow', 'hidden');
$('section').scrollable({ circular: true }).navigator();
var api = $('section').data("scrollable");//get access to the api functions
api.onBeforeSeek(function(){
//do something and after this start sliding to the next img
}
http://jsfiddle.net/micka/zhDGC/
Strangely enough in the fiddle connecting to the api makes the slider break...
Any suggestions can help. Thanks! Michaël