Skip to content

Commit

Permalink
YAPL 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Commenter25 committed Jan 10, 2023
1 parent e5310bd commit 4120ed5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/), and

Past versions will link to their respective commit. Current versions will not due to temporal paradoxes.

## 2023-01-07 - 1.0.0
## 2023-01-10 - 1.0.1
Fixed:
- Only counts files once if multiple events are fired from one asset
- Assets are no longer shown in a11y tree
- Assets are no longer focusable

## 2023-01-07 - [1.0.0](https://github.com/Commenter25/YAPL/blob/cc3600cc1c7ed7c3f2eac171fceb687a1e11dfff/yapl.js)
Initial release
17 changes: 12 additions & 5 deletions yapl.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! @license Yet Another PreLoader v1.0.0 | Copyright (c) 2023 Commenter25 | MIT License */
/*! @license Yet Another PreLoader v1.0.1 | Copyright (c) 2023 Commenter25 | MIT License */
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT License */
/* jshint esversion: 6, browser: true, devel: true, strict: global */ "use strict";

Expand Down Expand Up @@ -35,7 +35,8 @@ try { return new Promise( (resolve)=> {

const tagLoader = document.createElement("div");
tagLoader.id = "yet-another-preloader";
tagLoader.style = "position: fixed; top: 99.9vh; left: 0; display: flex; opacity: 0.01";
tagLoader.style = "position: fixed; top: 99.9vh; left: 0; display: flex; opacity: 0.01; user-select: none; pointer-events: none";
tagLoader.setAttribute('aria-hidden', 'true');
document.body.prepend(tagLoader);

const increment = worked => {
Expand All @@ -50,19 +51,25 @@ try { return new Promise( (resolve)=> {
};

const loadTag =(tag, file)=> {
let done = false;
function good() {
if (done) return;
// console.log(`YAPL: ${file} loaded successfully!`);
tagLoader.appendChild(tag);
increment(true);
increment(true); done = true;
}
function bad() {
if (done) return;
console.error(`YAPL: ${file} couldn't load!`);
increment(false);
increment(false); done = true;
}

tag.src = file;
tag.style.width = "1px"; tag.style.height = "1px";
tag.tabIndex = -1;
tag.setAttribute('aria-hidden', 'true');
tag.alt = "";
tag.controls = true;
tag.style = "width: 1px; height: 1px";
tag.addEventListener("load", good);
tag.addEventListener("canplay", good);
tag.addEventListener("error", bad);
Expand Down

0 comments on commit 4120ed5

Please sign in to comment.