From f5c675ace48b76094e567000ce4bb7d282a9cf26 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 2 Feb 2022 22:17:39 +0100 Subject: [PATCH] only start moving the background once the page has fully loaded --- web/_includes/top.html | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/web/_includes/top.html b/web/_includes/top.html index 3634419..77c7233 100644 --- a/web/_includes/top.html +++ b/web/_includes/top.html @@ -35,13 +35,16 @@ let background = $(".top"); background.css("background-position", `${x}% ${y}%`); - setInterval(function () { - x += addX; - y += addY; - if (x < 0 || x > 100) - addX *= -1; - if (y < 0 || y > 100) - addY *= -1; - background.css("background-position", `${x}% ${y}%`); - }, 30); + + $(window).on("load", function () { + setInterval(function () { + x += addX; + y += addY; + if (x < 0 || x > 100) + addX *= -1; + if (y < 0 || y > 100) + addY *= -1; + background.css("background-position", `${x}% ${y}%`); + }, 30); + }); \ No newline at end of file