Place gifs correctly regardless of center tag (#16404)

* place gifs correctly regardless of center tag

* typo

* make sure the same gif src can be used twice in a post

* approach in css
This commit is contained in:
Suzanne Aitchison 2022-02-03 15:44:44 +00:00 committed by GitHub
parent a1eb6358db
commit 3454750ad3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -622,3 +622,9 @@ article {
}
}
}
// When a user has wrapped their gif in a <center> we don't want to manipulate the position
center .ff-container {
left: unset;
transform: none;
}

View file

@ -16,13 +16,17 @@ export const initializePausableAnimatedImages = (animatedImages = []) => {
if (animatedImages.length > 0) {
const freezeframes = [];
// Remove the surrounding links for the image, so it can be clicked to play/pause
for (const image of animatedImages) {
for (let i = 0; i < animatedImages.length; i++) {
const image = animatedImages[i];
// Give the image an ID so that we can uniquely target it in freezeframe
image.setAttribute('id', `animated-${i}`);
// Remove the surrounding links for the image, so it can be clicked to play/pause
image.closest('a').outerHTML = image.outerHTML;
freezeframes.push(
new Freezeframe({
selector: `img[src="${image.getAttribute('src')}"]`,
selector: `img[id='animated-${i}']`,
responsive: false,
trigger: 'click',
}),