fix slider
This commit is contained in:
parent
77a9f5ee88
commit
619f50d794
2 changed files with 16 additions and 8 deletions
|
|
@ -28,6 +28,7 @@ const state = {
|
||||||
viewMode: 'chat', // 'chat' or 'video'
|
viewMode: 'chat', // 'chat' or 'video'
|
||||||
iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
|
iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
|
||||||
peerGainNodes: new Map(), // userId -> GainNode
|
peerGainNodes: new Map(), // userId -> GainNode
|
||||||
|
visibleVolumeSliders: new Set(), // userIds whose sliders are visible
|
||||||
},
|
},
|
||||||
voicePresencePollId: null,
|
voicePresencePollId: null,
|
||||||
onlineUsers: new Set(),
|
onlineUsers: new Set(),
|
||||||
|
|
@ -416,8 +417,9 @@ function renderChannels() {
|
||||||
let sliderHtml = '';
|
let sliderHtml = '';
|
||||||
if (p.user_id !== state.me.id) {
|
if (p.user_id !== state.me.id) {
|
||||||
const vol = state.userVolumes.get(p.user_id) ?? 1.0;
|
const vol = state.userVolumes.get(p.user_id) ?? 1.0;
|
||||||
|
const isVisible = state.voice.visibleVolumeSliders.has(p.user_id);
|
||||||
sliderHtml = `
|
sliderHtml = `
|
||||||
<div class="user-volume-control" data-user-id="${p.user_id}">
|
<div class="user-volume-control ${isVisible ? 'show-volume' : ''}" data-user-id="${p.user_id}">
|
||||||
<i data-lucide="volume-2" style="width: 12px; height: 12px; opacity: 0.6;"></i>
|
<i data-lucide="volume-2" style="width: 12px; height: 12px; opacity: 0.6;"></i>
|
||||||
<input type="range" min="0" max="2" step="0.1" value="${vol}" class="volume-slider">
|
<input type="range" min="0" max="2" step="0.1" value="${vol}" class="volume-slider">
|
||||||
<span class="vol-pct">${Math.round(vol * 100)}%</span>
|
<span class="vol-pct">${Math.round(vol * 100)}%</span>
|
||||||
|
|
@ -454,10 +456,12 @@ function renderChannels() {
|
||||||
pRow.addEventListener('contextmenu', (e) => {
|
pRow.addEventListener('contextmenu', (e) => {
|
||||||
if (p.user_id === state.me.id) return;
|
if (p.user_id === state.me.id) return;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const control = pRow.querySelector('.user-volume-control');
|
if (state.voice.visibleVolumeSliders.has(p.user_id)) {
|
||||||
if (control) {
|
state.voice.visibleVolumeSliders.delete(p.user_id);
|
||||||
control.classList.toggle('show-volume');
|
} else {
|
||||||
|
state.voice.visibleVolumeSliders.add(p.user_id);
|
||||||
}
|
}
|
||||||
|
renderChannels();
|
||||||
});
|
});
|
||||||
|
|
||||||
pList.appendChild(pRow);
|
pList.appendChild(pRow);
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ const state = {
|
||||||
viewMode: 'chat', // 'chat' or 'video'
|
viewMode: 'chat', // 'chat' or 'video'
|
||||||
iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
|
iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
|
||||||
peerGainNodes: new Map(), // userId -> GainNode
|
peerGainNodes: new Map(), // userId -> GainNode
|
||||||
|
visibleVolumeSliders: new Set(), // userIds whose sliders are currently visible
|
||||||
},
|
},
|
||||||
voicePresencePollId: null,
|
voicePresencePollId: null,
|
||||||
chatWs: null,
|
chatWs: null,
|
||||||
|
|
@ -371,8 +372,9 @@ function renderChannels() {
|
||||||
let sliderHtml = '';
|
let sliderHtml = '';
|
||||||
if (p.user_id !== state.me.id) {
|
if (p.user_id !== state.me.id) {
|
||||||
const vol = state.userVolumes.get(p.user_id) ?? 1.0;
|
const vol = state.userVolumes.get(p.user_id) ?? 1.0;
|
||||||
|
const isVisible = state.voice.visibleVolumeSliders.has(p.user_id);
|
||||||
sliderHtml = `
|
sliderHtml = `
|
||||||
<div class="user-volume-control" data-user-id="${p.user_id}">
|
<div class="user-volume-control ${isVisible ? 'show-volume' : ''}" data-user-id="${p.user_id}">
|
||||||
<i data-lucide="volume-2" style="width: 12px; height: 12px; opacity: 0.6;"></i>
|
<i data-lucide="volume-2" style="width: 12px; height: 12px; opacity: 0.6;"></i>
|
||||||
<input type="range" min="0" max="2" step="0.1" value="${vol}" class="volume-slider">
|
<input type="range" min="0" max="2" step="0.1" value="${vol}" class="volume-slider">
|
||||||
<span class="vol-pct">${Math.round(vol * 100)}%</span>
|
<span class="vol-pct">${Math.round(vol * 100)}%</span>
|
||||||
|
|
@ -409,10 +411,12 @@ function renderChannels() {
|
||||||
pRow.addEventListener('contextmenu', (e) => {
|
pRow.addEventListener('contextmenu', (e) => {
|
||||||
if (p.user_id === state.me.id) return;
|
if (p.user_id === state.me.id) return;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const control = pRow.querySelector('.user-volume-control');
|
if (state.voice.visibleVolumeSliders.has(p.user_id)) {
|
||||||
if (control) {
|
state.voice.visibleVolumeSliders.delete(p.user_id);
|
||||||
control.classList.toggle('show-volume');
|
} else {
|
||||||
|
state.voice.visibleVolumeSliders.add(p.user_id);
|
||||||
}
|
}
|
||||||
|
renderChannels();
|
||||||
});
|
});
|
||||||
|
|
||||||
pList.appendChild(pRow);
|
pList.appendChild(pRow);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue