mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 17:47:16 +00:00
Avoid flash of no background when switching background images
This commit is contained in:
parent
ac2f80cc0c
commit
a1139ec371
1 changed files with 12 additions and 1 deletions
|
|
@ -351,7 +351,18 @@ export function findXmlElementById(
|
|||
// This is intentionally async since we may want to sub it out for an async
|
||||
// function in a node environment
|
||||
export async function getUrlFromBlob(blob: Blob): Promise<string> {
|
||||
return URL.createObjectURL(blob);
|
||||
// We initiallay used `URL.createObjectURL(blob)` here, but it had an issue
|
||||
// where, when used as a background imaged, they would take more than one
|
||||
// frame to load resulting in a white flash when switching background iamges.
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
// @ts-ignore This API is not very type-friendly.
|
||||
resolve(e.target.result);
|
||||
};
|
||||
reader.onerror = reject;
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
}
|
||||
|
||||
async function loadImage(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue