img src没有在firefox和edge中更新

时间:2017-03-05 11:03:26

标签: javascript html firefox microsoft-edge

(不是我的代码)

我正在测试我搜索过的一些代码(Code Page),出于某种原因,当img src正在更新时,图像保持不变。

示例> http://awardwinningfjords.com/projects/sequence/apple

function rightNow() {
  if (window['performance'] && window['performance']['now']) {
    return window['performance']['now']();
  } else {
    return +(new Date());
  }
}

var fps          = 30,
    currentFrame = 0,
    totalFrames  = 60,
    img          = document.getElementById("myImage"),
    currentTime  = rightNow();

(function animloop(time){
  var delta = (time - currentTime) / 1000;

  currentFrame += (delta * fps);

  var frameNum = Math.floor(currentFrame);

  if (frameNum >= totalFrames) {
    currentFrame = frameNum = 0;
  }

  requestAnimationFrame(animloop);

  img.src = "/projects/sequence/particle-hover/particle_hover_04_000" +
    (frameNum < 10 ? "0" : "") + frameNum + ".png";

  currentTime = time;
})(currentTime);

0 个答案:

没有答案