Skip to content

Commit

Permalink
v0.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
skyrim committed Sep 8, 2024
1 parent a82f7ed commit 8e18cca
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hlviewer.js",
"version": "0.8.0",
"version": "0.8.1",
"description": "View GoldSrc maps and replays in browser",
"keywords": [
"hlviewer",
Expand Down
3 changes: 0 additions & 3 deletions src/PlayerInterface/TimeLine/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export function Timeline(props: { game: Game }) {
})
})

let isMouseDown = false
const onMouseDown = (e: MouseEvent & { currentTarget: HTMLButtonElement }) => {
isMouseDown = true
const rects = e.currentTarget.getClientRects()[0]
const progress = 1 - (rects.right - e.pageX) / (rects.right - rects.left)
props.game.player.seekByPercent(progress * 100)
Expand All @@ -35,7 +33,6 @@ export function Timeline(props: { game: Game }) {
window.addEventListener(
'mouseup',
() => {
isMouseDown = false
window.removeEventListener('mousemove', onMouseMove)
},
{ once: true }
Expand Down
7 changes: 1 addition & 6 deletions src/PlayerInterface/VolumeControl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,19 @@ import './style.css'
export function VolumeControl(props: { game: Game }) {
const gameState = useGameState()

let isMouseDown = false
const onMouseDown = (e: MouseEvent & { currentTarget: HTMLDivElement }) => {
isMouseDown = true
const rects = e.currentTarget.getClientRects()[0]
const volume = 1 - (rects.right - e.pageX) / (rects.right - rects.left)
props.game.soundSystem.setVolume(volume)

const onMouseMove = (e: MouseEvent) => {
const volume = Math.max(0, Math.min(1 - (rects.right - e.pageX) / (rects.right - rects.left), 1))
if (isMouseDown) {
props.game.soundSystem.setVolume(volume)
}
props.game.soundSystem.setVolume(volume)
}
window.addEventListener('mousemove', onMouseMove)
window.addEventListener(
'mouseup',
() => {
isMouseDown = false
window.removeEventListener('mousemove', onMouseMove)
},
{ once: true }
Expand Down

0 comments on commit 8e18cca

Please sign in to comment.