Skip to content

Commit

Permalink
update media example
Browse files Browse the repository at this point in the history
check for length and avoid setting slider value less than 0
  • Loading branch information
Aylur committed Apr 8, 2024
1 parent d589077 commit 7525198
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions example/media-widget/Media.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ function Player(player) {
class_name: "position",
draw_value: false,
on_change: ({ value }) => player.position = value * player.length,
visible: player.bind("length").as(l => l > 0),
setup: self => {
const update = () => {
self.visible = player.length > 0
self.value = player.position / player.length
function update() {
const value = player.position / player.length
self.value = value > 0 ? value : 0
}
self.hook(player, update)
self.hook(player, update, "position")
Expand Down

0 comments on commit 7525198

Please sign in to comment.