FIX: Support pausing inline animated images (#13033)
This commit is contained in:
parent
f9bb6399e0
commit
b0d66b4b2f
|
@ -20,8 +20,10 @@ function _pauseAnimation(img, opts = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _resumeAnimation(img) {
|
function _resumeAnimation(img) {
|
||||||
img.previousSibling.remove();
|
if (img.previousSibling && img.previousSibling.nodeName === "CANVAS") {
|
||||||
img.parentNode.classList.remove("paused-animated-image", "manually-paused");
|
img.previousSibling.remove();
|
||||||
|
}
|
||||||
|
img.parentNode.classList.remove("paused-animated-image");
|
||||||
}
|
}
|
||||||
|
|
||||||
function animatedImgs() {
|
function animatedImgs() {
|
||||||
|
@ -83,13 +85,18 @@ export default {
|
||||||
img.addEventListener("load", _handleEvent, false);
|
img.addEventListener("load", _handleEvent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
img.parentNode.classList.add("pausable-animated-image");
|
const wrapper = document.createElement("div"),
|
||||||
const overlay = document.createElement("div");
|
overlay = document.createElement("div");
|
||||||
|
|
||||||
|
img.parentNode.insertBefore(wrapper, img);
|
||||||
|
wrapper.classList.add("pausable-animated-image");
|
||||||
|
wrapper.appendChild(img);
|
||||||
|
|
||||||
overlay.classList.add("animated-image-overlay");
|
overlay.classList.add("animated-image-overlay");
|
||||||
overlay.setAttribute("aria-hidden", "true");
|
overlay.setAttribute("aria-hidden", "true");
|
||||||
overlay.setAttribute("role", "presentation");
|
overlay.setAttribute("role", "presentation");
|
||||||
overlay.innerHTML = `${iconHTML("pause")}${iconHTML("play")}`;
|
overlay.innerHTML = `${iconHTML("pause")}${iconHTML("play")}`;
|
||||||
img.parentNode.appendChild(overlay);
|
wrapper.appendChild(overlay);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue