解決したいことは、以下のコードでテンプレートリテラルを文字列に修正できたのですが、
IE11でデバッグしたところ、constとletでもバグが発生しておりました。
ご教授いただけますでしょうか。
const $element = $j('.hanabira-anime'); const imagePath = 'dummy/'; const totalFrames = 100; const animationDuration = 10000; const timePerFrame = animationDuration / totalFrames; let timeWhenLastUpdate; let timeFromLastUpdate; let frameNumber = 1; function step(startTime) { if (!timeWhenLastUpdate) timeWhenLastUpdate = startTime; timeFromLastUpdate = startTime - timeWhenLastUpdate; // then we check if it is time to update the frame if (timeFromLastUpdate > timePerFrame) { // and update it accordingly $element.attr('src', imagePath + "img/hanabira/Par_hanabira"+frameNumber + '.png'); // reset the last update time timeWhenLastUpdate = startTime; // then increase the frame number or reset it if it is the last frame if (frameNumber >= totalFrames) { frameNumber = 1; } else { frameNumber = frameNumber + 1; } } requestAnimationFrame(step); } $j(document).ready(() => { for (var i = 1; i < totalFrames + 1; i++) { $j('body').append('<div id="preload-image-' + i + '" style="background-image: url(\'' + imagePath + 'img/hanabira/Par_hanabira'+ i + '.png");"></div>'); } }); // wait for images to be downloaded and start the animation $j(window).on('load', () => { requestAnimationFrame(step); });
回答1件
あなたの回答
tips
プレビュー