Fix seek bar sometimes becoming empty when one seek section is completely filled

This commit is contained in:
Ajay
2022-09-14 02:58:22 -04:00
parent d9e723b265
commit b0e1d5e7fa

View File

@@ -584,6 +584,7 @@ class PreviewBar {
{ left: number, scale: number } { { left: number, scale: number } {
const sections = currentElement.parentElement.parentElement.parentElement.children; const sections = currentElement.parentElement.parentElement.parentElement.children;
let currentWidth = 0; let currentWidth = 0;
let lastWidth = 0;
let left = 0; let left = 0;
let leftPosition = 0; let leftPosition = 0;
@@ -591,6 +592,7 @@ class PreviewBar {
let scale = null; let scale = null;
let scalePosition = 0; let scalePosition = 0;
let scaleWidth = 0; let scaleWidth = 0;
let lastScalePosition = 0;
for (let i = 0; i < sections.length; i++) { for (let i = 0; i < sections.length; i++) {
const section = sections[i] as HTMLElement; const section = sections[i] as HTMLElement;
@@ -610,12 +612,21 @@ class PreviewBar {
const transformMatch = checkElement.style.transform.match(/scaleX\(([0-9.]+?)\)/); const transformMatch = checkElement.style.transform.match(/scaleX\(([0-9.]+?)\)/);
if (transformMatch) { if (transformMatch) {
const transformScale = parseFloat(transformMatch[1]); const transformScale = parseFloat(transformMatch[1]);
if (i === sections.length - 1 || (transformScale < 1 && transformScale + checkLeft / currentSectionWidthNoMargin < 0.99999)) { const endPosition = transformScale + checkLeft / currentSectionWidthNoMargin;
if (lastScalePosition > 0.99999 && endPosition === 0) {
// Last one was an end section that was fully filled
scalePosition = currentWidth - lastWidth;
break;
}
lastScalePosition = endPosition;
scale = transformScale; scale = transformScale;
scaleWidth = currentSectionWidthNoMargin; scaleWidth = currentSectionWidthNoMargin;
if (transformScale > 0) { if ((i === sections.length - 1 || endPosition < 0.99999) && endPosition > 0) {
// reached the end of this section for sure, since the scale is now between 0 and 1 // reached the end of this section for sure
// if the scale is always zero, then it will go through all sections but still return 0 // if the scale is always zero, then it will go through all sections but still return 0
scalePosition = currentWidth; scalePosition = currentWidth;
@@ -625,9 +636,9 @@ class PreviewBar {
break; break;
} }
} }
}
currentWidth += currentSectionWidth; lastWidth = currentSectionWidth;
currentWidth += lastWidth;
} }
return { return {