Skip to content

Commit

Permalink
Make gradiant display for chapter seek bar follow the same UI as YouTube
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayyy committed Oct 18, 2024
1 parent 510c372 commit 875ec35
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/js-components/previewBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,15 @@ class PreviewBar {
customChangedElement.style.transform =
`scaleX(${scale})`;
if (customChangedElement.style.backgroundSize) {
const backgroundSize = progressBar.clientWidth;
const backgroundSize = Math.max(changedData.scale / scale, fullSectionWidth * progressBar.clientWidth);
customChangedElement.style.backgroundSize = `${backgroundSize}px`;

customChangedElement.style.backgroundPosition = `${-(cursor * progressBar.clientWidth)}px`;
if (changedData.scale < (cursor + fullSectionWidth) * progressBar.clientWidth) {
customChangedElement.style.backgroundPosition = `-${backgroundSize - fullSectionWidth * progressBar.clientWidth}px`;
} else {
// Passed this section
customChangedElement.style.backgroundPosition = `-${cursor * progressBar.clientWidth}px`;
}
}

if (firstUpdate) {
Expand Down

0 comments on commit 875ec35

Please sign in to comment.