1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-12-03 13:21:34 +00:00

fix: constructBarStyle

This commit is contained in:
Braeden 2024-10-27 17:22:04 -04:00
parent d1da81c1f8
commit d4136f72da

View file

@ -89,9 +89,12 @@ function updateOomps(diff)
function constructBarStyle(layer, id) {
let bar = tmp[layer].bars[id]
let style = {}
let tempProgress
if (bar.progress instanceof Decimal)
bar.progress = bar.progress.toNumber()
bar.progress = (1 -Math.min(Math.max(bar.progress, 0), 1)) * 100
tempProgress = (1 -Math.min(Math.max(bar.progress.toNumber(), 0), 1)) * 100
else
tempProgress = (1 -Math.min(Math.max(bar.progress, 0), 1)) * 100
style.dims = {'width': bar.width + "px", 'height': bar.height + "px"}
let dir = bar.direction
@ -99,19 +102,19 @@ function constructBarStyle(layer, id) {
switch(bar.direction) {
case UP:
style.fillDims['clip-path'] = 'inset(' + bar.progress + '% 0% 0% 0%)'
style.fillDims['clip-path'] = 'inset(' + tempProgress + '% 0% 0% 0%)'
style.fillDims.width = bar.width + 1 + 'px'
break;
case DOWN:
style.fillDims['clip-path'] = 'inset(0% 0% ' + bar.progress + '% 0%)'
style.fillDims['clip-path'] = 'inset(0% 0% ' + tempProgress + '% 0%)'
style.fillDims.width = bar.width + 1 + 'px'
break;
case RIGHT:
style.fillDims['clip-path'] = 'inset(0% ' + bar.progress + '% 0% 0%)'
style.fillDims['clip-path'] = 'inset(0% ' + tempProgress + '% 0% 0%)'
break;
case LEFT:
style.fillDims['clip-path'] = 'inset(0% 0% 0% ' + bar.progress + '%)'
style.fillDims['clip-path'] = 'inset(0% 0% 0% ' + tempProgress + '%)'
break;
case DEFAULT:
style.fillDims['clip-path'] = 'inset(0% 50% 0% 0%)'