Skip to content

Commit

Permalink
fix: restrict slider range
Browse files Browse the repository at this point in the history
  • Loading branch information
Honoka55 committed Feb 28, 2024
1 parent eceeec2 commit 058055f
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,26 @@ window.onload = () => {
[drawTriangle, hikari1X - 93, 224, hikari1X - 87, 223, hikari1X - 89, 235]
]);

const sliderMin = Math.round(tenX + 180);
const sliderMax = Math.round(textX + 33);
const sliderValue = Math.max(sliderMin, Math.min(sliderMax, Math.round(textX - 0.18 * (textX - tenX))));
slider.setAttribute('min', sliderMin);
slider.setAttribute('max', sliderMax);
slider.setAttribute('value', sliderValue);
slider.setAttribute('text1', text1);
slider.setAttribute('text2', text2);
slider.setAttribute('ten', ten);
slider.setAttribute('text3', text3);
slider.removeAttribute('disabled');

if (!hikari2X) {
hikari2X = textX - 0.18 * (textX - tenX);
hikari2X = sliderValue;
}
if (hikari2X < sliderMin) {
hikari2X = sliderMin;
}
if (hikari2X > sliderMax) {
hikari2X = sliderMax;
}
drawSet([
[drawHikari, hikari2X - 150, 156, 1],
Expand Down Expand Up @@ -270,15 +288,6 @@ window.onload = () => {
ctx.clearRect(canvas.width - 210, 0, canvas.width, 20);
});

slider.setAttribute('min', Math.round(tenX + 180));
slider.setAttribute('max', canvas.width - 40);
slider.setAttribute('value', Math.round(hikari2X));
slider.setAttribute('text1', text1);
slider.setAttribute('text2', text2);
slider.setAttribute('ten', ten);
slider.setAttribute('text3', text3);
slider.removeAttribute('disabled');

nightcord.style.cursor = 'pointer';
nightcord.addEventListener('click', () => {
if (copyright.style.maxHeight == '0px') {
Expand Down

0 comments on commit 058055f

Please sign in to comment.