mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
make background changing more instant
This commit is contained in:
@@ -17,17 +17,6 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
|
|
||||||
animation: fade 0.4s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes fade {
|
|
||||||
0% {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ const readData = async () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function to update the background
|
|
||||||
const updateBackground = async () => {
|
const updateBackground = async () => {
|
||||||
try {
|
try {
|
||||||
const data = await readData();
|
const data = await readData();
|
||||||
@@ -43,21 +42,39 @@ const updateBackground = async () => {
|
|||||||
|
|
||||||
const url = URL.createObjectURL(data.blob);
|
const url = URL.createObjectURL(data.blob);
|
||||||
const container = document.getElementById("media-container");
|
const container = document.getElementById("media-container");
|
||||||
container.innerHTML = ""; // Clear previous background
|
|
||||||
|
|
||||||
|
// Create new element and set properties
|
||||||
|
let newElement;
|
||||||
if (data.type === "image") {
|
if (data.type === "image") {
|
||||||
const imgElement = document.createElement("img");
|
newElement = document.createElement("img");
|
||||||
imgElement.src = url;
|
newElement.src = url;
|
||||||
imgElement.alt = "Uploaded content";
|
newElement.alt = "Uploaded content";
|
||||||
container.appendChild(imgElement);
|
|
||||||
} else if (data.type === "video") {
|
} else if (data.type === "video") {
|
||||||
const videoElement = document.createElement("video");
|
newElement = document.createElement("video");
|
||||||
videoElement.src = url;
|
newElement.src = url;
|
||||||
videoElement.autoplay = true;
|
newElement.autoplay = true;
|
||||||
videoElement.loop = true;
|
newElement.loop = true;
|
||||||
videoElement.muted = true;
|
newElement.muted = true;
|
||||||
container.appendChild(videoElement);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mark the old element for removal
|
||||||
|
const oldElement = container.querySelector(".current-media");
|
||||||
|
if (oldElement) {
|
||||||
|
oldElement.classList.remove("current-media");
|
||||||
|
oldElement.classList.add("old-media");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the new element and mark it as current
|
||||||
|
newElement.classList.add("current-media");
|
||||||
|
container.appendChild(newElement);
|
||||||
|
|
||||||
|
// Delay removal of old element
|
||||||
|
setTimeout(() => {
|
||||||
|
const oldMedia = container.querySelector(".old-media");
|
||||||
|
if (oldMedia) {
|
||||||
|
oldMedia.remove();
|
||||||
|
}
|
||||||
|
}, 100); // 0.1 second delay
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("An error occurred:", error);
|
console.error("An error occurred:", error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user