I developed a progress bar that, when clicked, advances every 25, starting at 0.
When loading the object, some of them already contain some progress. My problem is that on the first click to advance the bar, sometimes it gets lost and I don't know why it happened. For example, progress is at 75%, when I click on it to advance to 100% it goes to 25% for no apparent reason. Does anyone know why this happened?
Code
upd(event, data) {
let percentage: number = Math.floor(
(event.layerX / (event.target.offsetWidth - 3)) * 100
);
const previous = parseInt(this.percentage);
if (previous > percentage) {
percentage = previous - 25;
} else {
percentage = previous + 25;
}
}