loops - Reverse carousel javascript -



loops - Reverse carousel javascript -

i have next code , need create button reverse moving direction everytime user clicks on it.

i need help, please.

var div_width = 87; var div_count = 15; var reset_offset = div_width * (div_count -1); function init() { // set initial position - note first div // off lefthand side for(i=0;i<div_count;i++) { var foo = document.getelementbyid('fooobject' + i); foo.style.left = ''+(i*div_width)+'px'; } domove(); } function domove() { for(i=0;i<div_count;i++) { var foo = document.getelementbyid('fooobject' + i); var left = parseint(foo.style.left); foo.style.left = '' + (left+1) + 'px'; if (left >= reset_offset) { foo.style.left = '' + (-div_width) + 'px'; } } settimeout(domove, 20); } init();

thank you!

more detailed here: http://jsfiddle.net/usjpzcbq/

javascript loops carousel reverse

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -