Merge 64c2616a80
into c92b0bc3a8
commit
8a31d89bbb
@ -1,19 +1,22 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
|
||||||
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<link rel="stylesheet" href="style.css" />
|
<link rel="stylesheet" href="style.css" />
|
||||||
<title>Auto Text Effect</title>
|
<title>Auto Text Effect</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
|
||||||
|
<body>
|
||||||
<h1 id="text">Starting...</h1>
|
<h1 id="text">Starting...</h1>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label for="speed">Speed:</label>
|
<label for="speed">Speed:</label>
|
||||||
<input type="number" name="speed" id="speed" value="1" min="1" max="10" step="1">
|
<input type="number" name="speed" id="speed" value="5" min="1" max="10" step="1">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="script.js"></script>
|
<script src="script.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -1,22 +1,21 @@
|
|||||||
const textEl = document.getElementById('text')
|
const textEl = document.getElementById('text');
|
||||||
const speedEl = document.getElementById('speed')
|
const speedEl = document.getElementById('speed');
|
||||||
const text = 'We Love Programming!'
|
const text = 'xAI is an AI company with the mission of advancing scientific discovery and gaining a deeper understanding of our universe.';
|
||||||
let idx = 1
|
let idx = 1;
|
||||||
let speed = 300 / speedEl.value
|
let speed = 300 / speedEl.value;
|
||||||
|
|
||||||
writeText()
|
writeText();
|
||||||
|
|
||||||
function writeText() {
|
function writeText() {
|
||||||
textEl.innerText = text.slice(0, idx)
|
textEl.innerText = text.slice(0, idx);
|
||||||
|
|
||||||
idx++
|
idx++;
|
||||||
|
|
||||||
if(idx > text.length) {
|
if(idx > text.length) {
|
||||||
idx = 1
|
idx = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(writeText, speed)
|
setTimeout(writeText, speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
speedEl.addEventListener('input', (e) => speed = 300 / e.target.value);
|
||||||
speedEl.addEventListener('input', (e) => speed = 300 / e.target.value)
|
|
@ -1,31 +1,39 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
|
||||||
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<link rel="stylesheet" href="style.css" />
|
<link rel="stylesheet" href="style.css" />
|
||||||
<title>Expanding Cards</title>
|
<title>Expanding Cards</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
|
||||||
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="panel active" style="background-image: url('https://images.unsplash.com/photo-1558979158-65a1eaa08691?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80')">
|
<div class="panel active"
|
||||||
|
style="background-image: url('https://images.unsplash.com/photo-1558979158-65a1eaa08691?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80')">
|
||||||
<h3>Explore The World</h3>
|
<h3>Explore The World</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel" style="background-image: url('https://images.unsplash.com/photo-1572276596237-5db2c3e16c5d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80')">
|
<div class="panel"
|
||||||
|
style="background-image: url('https://images.unsplash.com/photo-1572276596237-5db2c3e16c5d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80')">
|
||||||
<h3>Wild Forest</h3>
|
<h3>Wild Forest</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel" style="background-image: url('https://images.unsplash.com/photo-1507525428034-b723cf961d3e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1353&q=80')">
|
<div class="panel"
|
||||||
|
style="background-image: url('https://images.unsplash.com/photo-1507525428034-b723cf961d3e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1353&q=80')">
|
||||||
<h3>Sunny Beach</h3>
|
<h3>Sunny Beach</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel" style="background-image: url('https://images.unsplash.com/photo-1551009175-8a68da93d5f9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1351&q=80')">
|
<div class="panel"
|
||||||
|
style="background-image: url('https://images.unsplash.com/photo-1551009175-8a68da93d5f9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1351&q=80')">
|
||||||
<h3>City on Winter</h3>
|
<h3>City on Winter</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel" style="background-image: url('https://images.unsplash.com/photo-1549880338-65ddcdfd017b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80')">
|
<div class="panel"
|
||||||
|
style="background-image: url('https://images.unsplash.com/photo-1549880338-65ddcdfd017b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80')">
|
||||||
<h3>Mountains - Clouds</h3>
|
<h3>Mountains - Clouds</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="script.js"></script>
|
<script src="script.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -1,49 +1,44 @@
|
|||||||
const progress = document.getElementById('progress')
|
const progress = document.getElementById('progress');
|
||||||
const prev = document.getElementById('prev')
|
const prev = document.getElementById('prev');
|
||||||
const next = document.getElementById('next')
|
const next = document.getElementById('next');
|
||||||
const circles = document.querySelectorAll('.circle')
|
const circles = document.querySelectorAll('.circle');
|
||||||
|
|
||||||
let currentActive = 1
|
let currentActive = 1;
|
||||||
|
|
||||||
next.addEventListener('click', () => {
|
next.addEventListener('click', () => {
|
||||||
currentActive++
|
currentActive++;
|
||||||
|
if (currentActive > circles.length) {
|
||||||
if(currentActive > circles.length) {
|
currentActive = circles.length;
|
||||||
currentActive = circles.length
|
|
||||||
}
|
}
|
||||||
|
update();
|
||||||
update()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
prev.addEventListener('click', () => {
|
prev.addEventListener('click', () => {
|
||||||
currentActive--
|
currentActive--;
|
||||||
|
if (currentActive < 1) {
|
||||||
if(currentActive < 1) {
|
currentActive = 1;
|
||||||
currentActive = 1
|
|
||||||
}
|
}
|
||||||
|
update();
|
||||||
update()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
circles.forEach((circle, idx) => {
|
circles.forEach((circle, idx) => {
|
||||||
if(idx < currentActive) {
|
if (idx < currentActive) {
|
||||||
circle.classList.add('active')
|
circle.classList.add('active');
|
||||||
} else {
|
} else {
|
||||||
circle.classList.remove('active')
|
circle.classList.remove('active');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const actives = document.querySelectorAll('.active')
|
const actives = document.querySelectorAll('.active');
|
||||||
|
progress.style.width = ((actives.length - 1) / (circles.length - 1)) * 100 + '%';
|
||||||
progress.style.width = (actives.length - 1) / (circles.length - 1) * 100 + '%'
|
|
||||||
|
|
||||||
if(currentActive === 1) {
|
if (currentActive === 1) {
|
||||||
prev.disabled = true
|
prev.disabled = true;
|
||||||
} else if(currentActive === circles.length) {
|
} else if (currentActive === circles.length) {
|
||||||
next.disabled = true
|
next.disabled = true;
|
||||||
} else {
|
} else {
|
||||||
prev.disabled = false
|
prev.disabled = false;
|
||||||
next.disabled = false
|
next.disabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in new issue