This commit is contained in:
Bruno Rybársky 2024-05-02 12:06:13 +02:00
parent d1945cfbd8
commit b25ad54107
3 changed files with 8 additions and 7 deletions

@ -15,7 +15,10 @@
<!-- Set the value to 0 if range is from -500 to 500 --> <!-- Set the value to 0 if range is from -500 to 500 -->
<input type="range" id="slider" min="-500" max="500" value="0"> <input type="range" id="slider" min="-500" max="500" value="0">
<br> <br>
<button id="resetovac">RESET</button> <select id="selector">
<option value="0">RESET</option>
<option value="112">Nahodne miesto</option>
</select>
</div> </div>
<script src="script.js"></script> <script src="script.js"></script>
</body> </body>

@ -1,11 +1,12 @@
document.getElementById('slider').addEventListener('input', updateImagePositions); document.getElementById('slider').addEventListener('input', updateImagePositions);
document.getElementById('resetovac').addEventListener('click', resetImagePositions); document.getElementById('selector').addEventListener('input', resetImagePositions);
updateImagePositions(); updateImagePositions();
function resetImagePositions() { function resetImagePositions() {
const slider = document.getElementById('slider'); const slider = document.getElementById('slider');
slider.value = 0; const selector = document.getElementById('selector');
slider.value = selector.value;
updateImagePositions(); updateImagePositions();
} }
@ -17,6 +18,7 @@ function updateImagePositions() {
const sliderMin = parseInt(slider.min); const sliderMin = parseInt(slider.min);
let sliderValue = parseInt(slider.value); let sliderValue = parseInt(slider.value);
console.log(sliderValue);
// Convert the slider value to a percentage offset within the specified range // Convert the slider value to a percentage offset within the specified range
let sliderMovePercent = ((sliderValue - sliderMin) / (sliderMax - sliderMin) * 2 - 1) * 100; let sliderMovePercent = ((sliderValue - sliderMin) / (sliderMax - sliderMin) * 2 - 1) * 100;

@ -5,13 +5,10 @@ body {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin: 0; margin: 0;
overflow: hidden; /* Prevent body from scrolling */
} }
#image-container { #image-container {
overflow: visible; /* Allow images to overflow */ overflow: visible; /* Allow images to overflow */
width: 100vw; /* Full viewport width */
height: auto; /* Height determined by image heights */
position: relative; /* Base positioning for relative image movement */ position: relative; /* Base positioning for relative image movement */
} }
@ -19,7 +16,6 @@ img {
display: block; display: block;
position: relative; /* Relative positioning */ position: relative; /* Relative positioning */
transition: left 0.3s ease; /* Smooth left transition */ transition: left 0.3s ease; /* Smooth left transition */
width: 100vw;
} }
#slider-container { #slider-container {