Не меняется значение переменной
Всем привет!
не пойму что не так: первый алерт выводит window.curr_el до его изменения (например 0), второй должен вывести 1 если direction == 1, но он тоже выводит 0!! при этом если его поставить сразу после ...fadeIn("200"); , то выводит инкрементированное значение! почему так и что сделать чтоб работал правильно? function step ( direction ){ console.log('<<< Начало шага.......'); console.log('current element - '+window.curr_el); console.log(JSON.stringify(matrix)); console.log('>>> Начало шага.......'); alert('old '+window.curr_el); jQuery( "#block_"+window.curr_el ).fadeOut( "200", function() { if ( direction == 0 && window.curr_el > window.first_el ) { window.curr_el--; } if ( direction == 1 && window.curr_el < window.last_el ) { window.curr_el++; } jQuery("#block_"+window.curr_el).fadeIn("200"); }); alert('new '+window.curr_el); console.log('<<< Конец шага.......'); console.log('current element - '+window.curr_el); console.log(JSON.stringify(matrix)); console.log('>>> Конец шага.......'); navControl(); } Спасибо! |
Цитата:
|
Часовой пояс GMT +3, время: 03:57. |