var play = function(val){ //読み込みの進行状況varpercent = Math.round(100 * store.length / maxLength); eleLoading.setAttribute( 'data-percent'、percent); eleLoading.style.backgroundSize = percent + ' %100% '; //成功か失敗かに関係なく、すべて読み込まれるif(percent == 100){ var index = val; // var index = indexRange [0]; eleContainer.innerHTML =' '; //画像を追加するturn Object var step = function(){ indexplay = index if(store [index-1]){ if(flag){ eleContainer.removeChild(store [index-1]); } } eleContainer.appendChild(store [index]) ; flag = true console.log( 'sssssss'、eleContainer)//シーケンスの増加
index ++;
// 如果超过最大限制
if (index <= indexRange[1]) {
timer = setTimeout(step, 500);
} else {
// 本段播放结束回调
// 我这里就放一个重新播放的按钮
eleContainer.insertAdjacentHTML('beforeEnd', '<button onclick="play()">再看一遍英姿</button>');
}
};
// 等100%动画结束后执行播放
setTimeout(step, 100);
}
};
function stop(val){ console.log( 'stop')clearTimeout(timer)} function play1(){ flag = false let indexplay2 = indexplay + 1 play(indexplay2)}