Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed Sep 26, 2022
1 parent 5fc11fb commit 3b30901
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/ui/src/components/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const highlightCls = $.css({
export default function (player: Player, container: HTMLElement, highlights: Highlight[] = []) {
const $dom = document.createDocumentFragment() as unknown as HTMLDivElement
let $highlights: HTMLDivElement[] = []
let active = true

function createDto(options: { left: number; text: string }) {
const dto = $.create(
Expand All @@ -56,10 +57,17 @@ export default function (player: Player, container: HTMLElement, highlights: Hig
}

player.on('videoinitialized', () => {
createHighlights(highlights, player.duration)
if (active) createHighlights(highlights, player.duration)
})

player.on('videosourcechange', () => {
active = false
$highlights.forEach((it) => it.remove())
})

player.on('highlightchange', () => {
active = true
$highlights.forEach((it) => it.remove())
createHighlights(highlights, player.duration)
})
}

1 comment on commit 3b30901

@vercel
Copy link

@vercel vercel bot commented on 3b30901 Sep 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

oplayer – ./

oplayer.vercel.app
oplayer-git-main-shiyiya.vercel.app
oplayer-shiyiya.vercel.app

Please sign in to comment.