var play = function (val) {
// loading进度
var percent = 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 = ‘’;
// 依次append图片对象
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)
}