mirror of
https://github.com/RetroDECK/RetroDECK-Website.git
synced 2024-11-25 08:05:38 +00:00
- Add reduce motion
- Randomize gradient motion
This commit is contained in:
parent
8972fbd3c9
commit
bd943af564
|
@ -40,7 +40,7 @@ footer {
|
||||||
}
|
}
|
||||||
|
|
||||||
.my-gradient {
|
.my-gradient {
|
||||||
background: linear-gradient(45deg, #1a9fff, #946beb);
|
background: linear-gradient(0deg, #1a9fff, #946beb);
|
||||||
}
|
}
|
||||||
|
|
||||||
.jumbotron h1 {
|
.jumbotron h1 {
|
||||||
|
|
|
@ -223,11 +223,17 @@
|
||||||
|
|
||||||
<!-- Footer -->
|
<!-- Footer -->
|
||||||
<footer class="container-fluid p-2">
|
<footer class="container-fluid p-2">
|
||||||
<div class="row text-center">
|
<div class="row justify-content-betweetn">
|
||||||
<div class="col">
|
<div class="col-md">
|
||||||
Created by <a target="_blank" rel="noopener noreferrer" href="https://github.com/jiannazzone">Adam
|
Created by <a target="_blank" rel="noopener noreferrer" href="https://github.com/jiannazzone">Adam
|
||||||
Iannazzone</a> and the RetroDECK team.
|
Iannazzone</a> and the RetroDECK team.
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md">
|
||||||
|
<div class="form-check form-switch float-end">
|
||||||
|
<input class="form-check-input" id="reduce-motion-switch" type="checkbox" role="switch" id="reduceMotionSwitch" onchange="reduceMotion()">
|
||||||
|
<label class="form-check-label" for="reduceMotionSwitch">Reduce motion</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<!-- End Footer -->
|
<!-- End Footer -->
|
||||||
|
|
10
index.html
10
index.html
|
@ -182,11 +182,17 @@
|
||||||
|
|
||||||
<!-- Footer -->
|
<!-- Footer -->
|
||||||
<footer class="container-fluid p-2">
|
<footer class="container-fluid p-2">
|
||||||
<div class="row text-center">
|
<div class="row justify-content-betweetn">
|
||||||
<div class="col">
|
<div class="col-md">
|
||||||
Created by <a target="_blank" rel="noopener noreferrer" href="https://github.com/jiannazzone">Adam
|
Created by <a target="_blank" rel="noopener noreferrer" href="https://github.com/jiannazzone">Adam
|
||||||
Iannazzone</a> and the RetroDECK team.
|
Iannazzone</a> and the RetroDECK team.
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-md">
|
||||||
|
<div class="form-check form-switch float-end">
|
||||||
|
<input class="form-check-input" id="reduce-motion-switch" type="checkbox" role="switch" id="reduceMotionSwitch" onchange="reduceMotion()">
|
||||||
|
<label class="form-check-label" for="reduceMotionSwitch">Reduce motion</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<!-- End Footer -->
|
<!-- End Footer -->
|
||||||
|
|
|
@ -1,16 +1,28 @@
|
||||||
let gradientAngle = 45;
|
|
||||||
|
|
||||||
let gradientSpinElems = document.getElementsByClassName('gradient-spin');
|
let gradientSpinElems = document.getElementsByClassName('gradient-spin');
|
||||||
const gradientInterval = setInterval(function() {
|
let gradientAngles = Array.from({ length: gradientSpinElems.length }, () => Math.floor(Math.random() * 361) + 1);
|
||||||
updateGradientAngle();
|
let gradientInterval;
|
||||||
}, 50);
|
|
||||||
|
reduceMotion();
|
||||||
|
|
||||||
function updateGradientAngle() {
|
function updateGradientAngle() {
|
||||||
gradientAngle += 1
|
for (let i = 0; i < gradientSpinElems.length; i++) {
|
||||||
if (gradientAngle > 360) {
|
gradientAngles[i] += Math.floor(Math.random() * 5) - 5;
|
||||||
gradientAngle = 0;
|
if (gradientAngles[i] > 360) {
|
||||||
|
gradientAngles[i] = 0;
|
||||||
}
|
}
|
||||||
for (let i=0; i<gradientSpinElems.length; i++) {
|
gradientSpinElems[i].style.background = `linear-gradient(${gradientAngles[i]}deg, #1a9fff, #946beb)`;
|
||||||
gradientSpinElems[i].style.background = `linear-gradient(${gradientAngle}deg, #1a9fff, #946beb)`;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function reduceMotion() {
|
||||||
|
let reduceMotionState = document.getElementById('reduce-motion-switch').checked;
|
||||||
|
console.log(reduceMotionState);
|
||||||
|
if (reduceMotionState) {
|
||||||
|
clearInterval(gradientInterval);
|
||||||
|
console.log('stopped');
|
||||||
|
} else {
|
||||||
|
gradientInterval = setInterval(function () {
|
||||||
|
updateGradientAngle();
|
||||||
|
}, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue