Skip to content

Commit

Permalink
completed text effect
Browse files Browse the repository at this point in the history
  • Loading branch information
tsr-kairi committed Jul 8, 2021
1 parent d47f802 commit 20c659e
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Day 30 - Auto Text Effect/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const textEl = document.getElementById("text");
const speedEl = document.getElementById("speed");
const text = "We Love Programming!";
let idx = 1;
let speed = 300 / speedEl.value;

writeText();

function writeText() {
textEl.innerText = text.slice(0, idx);

idx++;

if (idx > text.length) {
idx = 1;
}

setTimeout(writeText, speed);
}

speedEl.addEventListener("input", (e) => (speed = 300 / e.target.value));
28 changes: 28 additions & 0 deletions Day 30 - Auto Text Effect/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./style.css" />
<title>Auto Text Effect</title>
</head>
<body>
<h1 id="text">Starting...</h1>

<div>
<label for="speed">Speed:</label>
<input
type="number"
name="speed"
id="speed"
value="1"
min="1"
max="10"
step="1"
/>
</div>

<script src="./app.js"></script>
</body>
</html>
39 changes: 39 additions & 0 deletions Day 30 - Auto Text Effect/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
*::after,
*::before {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
background-color: darksalmon;
font-family: "Roboto", sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
margin: 0;
}

div {
position: absolute;
bottom: 20px;
background: rgba(0, 0, 0, 0.1);
padding: 10px 20px;
font-size: 18px;
}

input {
width: 50px;
padding: 5px;
font-size: 18px;
background-color: darksalmon;
border: none;
text-align: center;
}

input:focus {
outline: none;
}

0 comments on commit 20c659e

Please sign in to comment.