Skip to content

Commit

Permalink
Add a button element to skipbutton
Browse files Browse the repository at this point in the history
  • Loading branch information
hanydd committed Dec 5, 2024
1 parent 54d7732 commit 7cf8952
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/js-components/skipButtonControlBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface SkipButtonControlBarProps {

export class SkipButtonControlBar {
container: HTMLElement;
skipButton: HTMLButtonElement;
skipIcon: HTMLImageElement;
// textContainer: HTMLElement;
// chapterText: HTMLElement;
Expand All @@ -34,19 +35,20 @@ export class SkipButtonControlBar {
this.container.classList.add("skipButtonControlBarContainer");
// this.container.classList.add("sbhidden");

const button = document.createElement("button");
button.classList.add("bpx-player-ctrl-btn", "playerButton");
button.id = "sbSkipIconControlBarButton";
this.skipButton = document.createElement("button");
this.skipButton.classList.add("bpx-player-ctrl-btn", "playerButton");
this.skipButton.id = "sbSkipIconControlBarButton";

this.skipIcon = document.createElement("img");
this.skipIcon.src = chrome.runtime.getURL("icons/skipIcon.svg");
this.skipIcon.classList.add("bpx-player-ctrl-btn-icon", "playerButtonImage");
this.skipIcon.id = "sbSkipIconControlBarImage";

this.skipButton.appendChild(this.skipIcon);

// this.textContainer = document.createElement("div");

button.appendChild(this.skipIcon);
this.container.appendChild(button);
this.container.appendChild(this.skipButton);
// this.container.appendChild(this.textContainer);
this.container.addEventListener("click", () => this.toggleSkip());
this.container.addEventListener("mouseenter", () => {
Expand Down Expand Up @@ -74,7 +76,7 @@ export class SkipButtonControlBar {

if (mountingContainer && !mountingContainer.contains(this.container)) {
mountingContainer.append(this.container);
AnimationUtils.setupAutoHideAnimation(this.skipIcon, mountingContainer, true, false);
AnimationUtils.setupAutoHideAnimation(this.skipButton, mountingContainer, false, false);
}
}

Expand All @@ -90,7 +92,7 @@ export class SkipButtonControlBar {
this.refreshText();
this.container?.classList?.remove("textDisabled");
// this.textContainer?.classList?.remove("sbhidden");
AnimationUtils.disableAutoHideAnimation(this.skipIcon);
AnimationUtils.disableAutoHideAnimation(this.skipButton);

this.startTimer();
}
Expand All @@ -100,7 +102,7 @@ export class SkipButtonControlBar {
// this.chapterText?.classList?.add("sbhidden");
this.container.classList.remove("sbhidden");
// this.textContainer.innerText = this.getTitle();
this.skipIcon.setAttribute("title", this.getTitle());
this.skipButton.setAttribute("title", this.getTitle());
}
}

Expand Down Expand Up @@ -154,7 +156,7 @@ export class SkipButtonControlBar {

this.getChapterPrefix()?.classList?.add("sbhidden");

AnimationUtils.enableAutoHideAnimation(this.skipIcon);
AnimationUtils.enableAutoHideAnimation(this.skipButton);
}

private getTitle(): string {
Expand Down

0 comments on commit 7cf8952

Please sign in to comment.