Skip to content

Commit

Permalink
调整音效选项为静音与否,统一样式
Browse files Browse the repository at this point in the history
  • Loading branch information
itorr committed Aug 24, 2022
1 parent 743e4e9 commit ee92f56
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
11 changes: 7 additions & 4 deletions html/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,18 @@ const Voices = {
chisato: new Audio('chinanago.mp3'),
takina: new Audio('sakana.mp3'),

isMute: voiceButton.classList.contains('voice-mute')
isMute: false
};

Voices.takina.volume = Voices.chisato.volume = 0.8;
Voices.takina.muted = Voices.chisato.muted = true;

const toggleVoiceMute = () => {
voiceButton.classList.toggle('voice-mute');
Voices.isMute = voiceButton.classList.contains('voice-mute');
Voices.isMute = voiceButton.getAttribute('data-active') !== 'true';
voiceButton.setAttribute(
'data-active',
Voices.isMute
);
Voices.takina.muted = Voices.chisato.muted = Voices.isMute;
};

Expand Down Expand Up @@ -316,7 +319,7 @@ el.ontouchstart = e=>{

const playVoice = () => {
if (Voices.isMute) return;
console.log({ r: v.r, y: v.y })
// console.log({ r: v.r, y: v.y })

if (el.classList.contains('chisato')) {
if (
Expand Down
18 changes: 11 additions & 7 deletions html/document.less
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,21 @@ canvas{
font-size: 12px;
line-height: 20px;
padding: 4px 4px;
overflow: hidden;
width: 50px;
a{
float: left;
padding:0 4px;
margin-top:2px;
border-radius:2px;
&[data-active="true"]{
background: #182562;
}
}
}
.trigger-magic-link{
&:before{
content: 'Auto';
}
&[data-active="true"]{
background: #182562;
content: '自动';
}
}

Expand Down Expand Up @@ -167,9 +171,9 @@ button{

&.voice-mute {
text-decoration: line-through;
&::before, &::after {
content: '\00a0';
}
// &::before, &::after {
// content: '\00a0';
// }
}
}

Expand Down
2 changes: 1 addition & 1 deletion html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
</div>
</div>
<div class="ctrl-box">
<a class="set-voice" onclick="toggleVoiceMute()">声音</a>
<a class="set-orientation-link" onclick="setOrientationListener()">陀螺仪</a>
<a class="set-voice" onclick="toggleVoiceMute()">静音</a>
<a class="trigger-magic-link" onclick="triggerMagic()"></a>
</div>
<footer>
Expand Down

0 comments on commit ee92f56

Please sign in to comment.