Skip to content

Commit

Permalink
chore(ui): correct type
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitalpopov committed Nov 14, 2024
1 parent 0523815 commit a3257ed
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/browser/topbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface TopBarOptions {

const browser = typeof window !== 'undefined'

let canvas: any
let canvas: HTMLCanvasElement
let progressTimerId: any
let fadeTimerId: any
let currentProgress: any
Expand Down Expand Up @@ -52,6 +52,8 @@ const repaint = () => {
canvas.height = options.barThickness * 5 // need space for shadow

const ctx = canvas.getContext('2d')
if (!ctx) return

ctx.shadowBlur = options.shadowBlur
ctx.shadowColor = options.shadowColor

Expand All @@ -68,7 +70,7 @@ const repaint = () => {
ctx.stroke()
}
const createCanvas = () => {
const canvas = document.createElement('canvas')
canvas = document.createElement('canvas')
canvas.ariaHidden = 'true'
const style = canvas.style
style.position = 'fixed'
Expand Down Expand Up @@ -104,7 +106,7 @@ export const topbar = {
window.cancelAnimationFrame(fadeTimerId)
}
if (!canvas) createCanvas()
canvas.style.opacity = 1
canvas.style.opacity = '1'
canvas.style.display = 'block'
topbar.progress(0)
if (options.autoRun) {
Expand Down Expand Up @@ -135,8 +137,8 @@ export const topbar = {
}
;(function loop() {
if (topbar.progress('+.1') >= 1) {
canvas.style.opacity -= 0.05
if (canvas.style.opacity <= 0.05) {
canvas.style.opacity = `${Number(canvas.style.opacity) - 0.05}`
if (Number(canvas.style.opacity) <= 0.05) {
canvas.style.display = 'none'
fadeTimerId = null
return
Expand Down

0 comments on commit a3257ed

Please sign in to comment.