Skip to content

Commit b62eca5

Browse files
committed
add sound to the typewrite letters
1 parent cf81c6e commit b62eca5

File tree

4 files changed

+33
-26
lines changed

4 files changed

+33
-26
lines changed

.DS_Store

0 Bytes
Binary file not shown.

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<!--cabecera-->
3131
<div id="header-fondo">
3232
<h1 class="text-crea"></h1>
33+
<audio id="sound-efx" src="styles/typewriter.wav"></audio>
3334
</div>
3435
<button id="button-down" type="button" name="button-down"><a href="index.html#empty-container"><img src="images/expand-button-medium.png" alt="rellena-los-campos"></a></button>
3536
<div id="empty-container"></div>

js/main.js

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,31 +90,36 @@ function viewprev(){
9090
}
9191

9292
// //Add typed text.
93-
// var idx = 0;
94-
// var txt = 'Crea tu CV con estilo...'.split('');
95-
// var speed = 150;
96-
// var waitOnFinish = 3000;
97-
// var textCreaEl = document.querySelector('.text-crea');
98-
//
99-
// document.addEventListener('DOMContentLoaded', typeWriter);
100-
//
101-
// function typeWriter() {
102-
// if (idx < txt.length) {
103-
// var tempTxt = textCreaEl.innerHTML;
104-
// textCreaEl.innerHTML += '|';
105-
// setTimeout(function() {
106-
// textCreaEl.innerHTML = tempTxt + txt[idx];
107-
// idx++;
108-
// setTimeout(typeWriter, speed);
109-
// }, speed/2);
110-
// } else {
111-
// idx = 0;
112-
// setTimeout(function(){
113-
// textCreaEl.innerHTML = '';
114-
// typeWriter();
115-
// }, waitOnFinish);
116-
// }
117-
// }
93+
var idx = 0;
94+
var txt = 'Crea tu CV con estilo...'.split('');
95+
var speed = 150;
96+
var waitOnFinish = 3000;
97+
var soundEfx = document.getElementById('sound-efx');
98+
var textCreaEl = document.querySelector('.text-crea');
99+
100+
document.addEventListener('DOMContentLoaded', typeWriter);
101+
102+
function typeWriter() {
103+
if (idx < txt.length) {
104+
var tempTxt = textCreaEl.innerHTML;
105+
textCreaEl.innerHTML += '|';
106+
setTimeout(function() {
107+
textCreaEl.innerHTML = tempTxt + txt[idx];
108+
idx++;
109+
soundEfx.play();
110+
setTimeout(typeWriter, speed);
111+
}, speed/2);
112+
} else {
113+
idx = 0;
114+
setTimeout(function(){
115+
textCreaEl.innerHTML = '';
116+
typeWriter();
117+
}, waitOnFinish);
118+
}
119+
}
120+
121+
//function sound
122+
118123

119124
/*--------------------------- ABOUT FUNCTION---------------------------------------*/
120125
function saveAbout(){

styles/styles.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ font-style: normal;
2525
font-weight: normal;
2626
src: local('American Typewriter Bold'), url('ufonts.com_american-typewriter-bold.woff') format('woff');
2727
}
28+
2829
/*Estilos generales de la sección de desplegables*/
2930
.title-container {
3031
padding-left: 20px;
@@ -97,7 +98,7 @@ src: local('American Typewriter Bold'), url('ufonts.com_american-typewriter-bold
9798
border-color:#7DBEA5;
9899
}
99100
/*Ocultar secciones*/
100-
.net-social-hidden, .invisible, #languages-form, #hobbies-form, #read, #travel, #game, #sports, #cinema, #music, #files, #ventana2 {
101+
.net-social-hidden, .invisible, #languages-form, #hobbies-form, #read, #travel, #game, #sports, #cinema, #music, #files, #ventana2, #sound-efx {
101102
display: none;
102103
}
103104
.visible {

0 commit comments

Comments
 (0)