mirror of
https://github.com/RetroDECK/RetroDECK-Website.git
synced 2024-11-21 22:45:39 +00:00
- Add reduce motion
- Randomize gradient motion
This commit is contained in:
parent
8972fbd3c9
commit
bd943af564
|
@ -40,7 +40,7 @@ footer {
|
|||
}
|
||||
|
||||
.my-gradient {
|
||||
background: linear-gradient(45deg, #1a9fff, #946beb);
|
||||
background: linear-gradient(0deg, #1a9fff, #946beb);
|
||||
}
|
||||
|
||||
.jumbotron h1 {
|
||||
|
|
|
@ -223,11 +223,17 @@
|
|||
|
||||
<!-- Footer -->
|
||||
<footer class="container-fluid p-2">
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<div class="row justify-content-betweetn">
|
||||
<div class="col-md">
|
||||
Created by <a target="_blank" rel="noopener noreferrer" href="https://github.com/jiannazzone">Adam
|
||||
Iannazzone</a> and the RetroDECK team.
|
||||
</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>
|
||||
</footer>
|
||||
<!-- End Footer -->
|
||||
|
|
10
index.html
10
index.html
|
@ -182,11 +182,17 @@
|
|||
|
||||
<!-- Footer -->
|
||||
<footer class="container-fluid p-2">
|
||||
<div class="row text-center">
|
||||
<div class="col">
|
||||
<div class="row justify-content-betweetn">
|
||||
<div class="col-md">
|
||||
Created by <a target="_blank" rel="noopener noreferrer" href="https://github.com/jiannazzone">Adam
|
||||
Iannazzone</a> and the RetroDECK team.
|
||||
</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>
|
||||
</footer>
|
||||
<!-- End Footer -->
|
||||
|
|
|
@ -1,16 +1,28 @@
|
|||
let gradientAngle = 45;
|
||||
|
||||
let gradientSpinElems = document.getElementsByClassName('gradient-spin');
|
||||
const gradientInterval = setInterval(function() {
|
||||
updateGradientAngle();
|
||||
}, 50);
|
||||
let gradientAngles = Array.from({ length: gradientSpinElems.length }, () => Math.floor(Math.random() * 361) + 1);
|
||||
let gradientInterval;
|
||||
|
||||
reduceMotion();
|
||||
|
||||
function updateGradientAngle() {
|
||||
gradientAngle += 1
|
||||
if (gradientAngle > 360) {
|
||||
gradientAngle = 0;
|
||||
for (let i = 0; i < gradientSpinElems.length; i++) {
|
||||
gradientAngles[i] += Math.floor(Math.random() * 5) - 5;
|
||||
if (gradientAngles[i] > 360) {
|
||||
gradientAngles[i] = 0;
|
||||
}
|
||||
gradientSpinElems[i].style.background = `linear-gradient(${gradientAngles[i]}deg, #1a9fff, #946beb)`;
|
||||
}
|
||||
for (let i=0; i<gradientSpinElems.length; i++) {
|
||||
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