javascript - Jquery Tools Scrollable onBeforeSeek function and then slide to next -



javascript - Jquery Tools Scrollable onBeforeSeek function and then slide to next -

i'm trying implement , customize little behavior of jquery tools scrollable plugin. want calling function just before sliding next item, waiting function complete , slide next item.

i tried out onbeforeseek function api, unfortunately calls desired function (like f.ex. settimeout) , doesn't wait finish, slides next item.

has thought how can prevent sliding next item until function completed? doesn't have occur absolutely trough onbeforeseek, seemed me ok, because summarizes result of several events 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 api functions api.onbeforeseek(function(){ //do , after start sliding next img }

http://jsfiddle.net/micka/zhdgc/

strangely plenty in fiddle connecting api makes slider break...

any suggestions can help. thanks! michaƫl

edit

so, want accomplish pause onbeforeseek event, stuff , fire again. purpose can utilize jquery plugins (simply google "jquery event pause resume"), 1 of them can found here.

if don't want utilize plugins or don't want deal events, can utilize solution in fiddle. instead of freezing , re-launching event cancels first time, animation, changes andimation status done , fires again, time without event cancellation.

var event_pos_list = [false, false, false]; api.onbeforeseek(function(event, pos){ // if animation not done - , skip scroll if(!event_pos_list[pos]){ event.preventdefault(); $('span').animate({marginleft: (pos*50) + 'px'}, 2000, function(){ // scroll, time animation completed event_pos_list[pos] = true; api.seekto(pos); }); } }); api.onseek(function(event, pos){ // after scroll done, reset event_pos_list event_pos_list[pos] = false; });

hope helps.

javascript jquery slider scrollable

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -