Fix group VN mode with reduced motion

179153ae67219dcaa8c8f15a1bdb97ea5d19ccbe

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +15 -3Ignore whitespace
public/scripts/extensions/expressions/index.js+15 -3
@@ -285,6 +285,12 @@ async function visualNovelUpdateLayers(container) {
285285 let images = Array.from($('#visual-novel-wrapper .expression-holder')).sort(sortFunction);
286286 let imagesWidth = [];
287287
288+ for (const image of images) {
289+ if (image instanceof HTMLImageElement && !image.complete) {
290+ await new Promise(resolve => image.addEventListener('load', resolve, { once: true }));
291+ }
292+ }
293+
288294 images.forEach(image => {
289295 imagesWidth.push($(image).width());
290296 });
@@ -320,9 +326,15 @@ async function visualNovelUpdateLayers(container) {
320326 element.show();
321327
322328 const promise = new Promise(resolve => {
323- element.animate({ left: currentPosition + 'px' }, 500, () => {
329+ if (power_user.reduced_motion) {
324- resolve();
330+ element.css('left', currentPosition + 'px');
325- });
331+ requestAnimationFrame(() => resolve());
332+ }
333+ else {
334+ element.animate({ left: currentPosition + 'px' }, 500, () => {
335+ resolve();
336+ });
337+ }
326338 });
327339
328340 currentPosition += imagesWidth[index];