Promotion (#2)

Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
2026-06-21 19:09:56 +00:00
parent dd507ca515
commit 11d923b72f
13 changed files with 10654 additions and 344 deletions
+6 -15
View File
@@ -41,15 +41,11 @@
ctx.shadowColor = options.shadowColor;
var lineGradient = ctx.createLinearGradient(0, 0, canvas.width, 0);
for (var stop in options.barColors)
lineGradient.addColorStop(stop, options.barColors[stop]);
for (var stop in options.barColors) lineGradient.addColorStop(stop, options.barColors[stop]);
ctx.lineWidth = options.barThickness;
ctx.beginPath();
ctx.moveTo(0, options.barThickness / 2);
ctx.lineTo(
Math.ceil(currentProgress * canvas.width),
options.barThickness / 2
);
ctx.lineTo(Math.ceil(currentProgress * canvas.width), options.barThickness / 2);
ctx.strokeStyle = lineGradient;
ctx.stroke();
},
@@ -65,8 +61,7 @@
},
topbar = {
config: function (opts) {
for (var key in opts)
if (options.hasOwnProperty(key)) options[key] = opts[key];
for (var key in opts) if (options.hasOwnProperty(key)) options[key] = opts[key];
},
show: function (delay) {
if (showing) return;
@@ -84,9 +79,7 @@
if (options.autoRun) {
(function loop() {
progressTimerId = window.requestAnimationFrame(loop);
topbar.progress(
"+" + 0.05 * Math.pow(1 - Math.sqrt(currentProgress), 2)
);
topbar.progress("+" + 0.05 * Math.pow(1 - Math.sqrt(currentProgress), 2));
})();
}
}
@@ -95,9 +88,7 @@
if (typeof to === "undefined") return currentProgress;
if (typeof to === "string") {
to =
(to.indexOf("+") >= 0 || to.indexOf("-") >= 0
? currentProgress
: 0) + parseFloat(to);
(to.indexOf("+") >= 0 || to.indexOf("-") >= 0 ? currentProgress : 0) + parseFloat(to);
}
currentProgress = to > 1 ? 1 : to;
repaint();
@@ -135,4 +126,4 @@
} else {
this.topbar = topbar;
}
}.call(this, window, document));
}).call(this, window, document);