how to calculate the fill color between dots in input type=”range” when min val is not 0

I am struggling with the calculation that is responsible for the fill color between the 2 dots in the range price-slider.

Part of the html for the range slider is:

 <div class="container">
    <div class="slider-track"></div>
    <input type="range" min="0" max="80" value="50" id="slider-1" oninput="slideOne()">
    <input type="range" min="0" max="80" value="70" id="slider-2" oninput="slideTwo()">
  </div>

The js:

window.onload = function () {
  slideOne();
  slideTwo();
};

let sliderOne = document.getElementById("slider-1");
let sliderTwo = document.getElementById("slider-2");
let displayValOne = document.getElementById("range1");
let displayValTwo = document.getElementById("range2");
let minGap = 5;
let sliderTrack = document.querySelector(".slider-track");
let sliderMaxValue = document.getElementById("slider-1").max;

function slideOne() {
  if (parseInt(sliderTwo.value) - parseInt(sliderOne.value) <= minGap) {
    sliderOne.value = parseInt(sliderTwo.value) - minGap;
  }
  displayValOne.textContent = sliderOne.value;
  fillColor();
}
function slideTwo() {
  if (parseInt(sliderTwo.value) - parseInt(sliderOne.value) <= minGap) {
    sliderTwo.value = parseInt(sliderOne.value) + minGap;
  }
  displayValTwo.textContent = sliderTwo.value;
  fillColor();
}
function fillColor() {
   percent1 = (sliderOne.value / sliderMaxValue) * 100;
   percent2 = (sliderTwo.value / sliderMaxValue) * 100;
   sliderTrack.style.background = `linear-gradient(to right, #dadae5 ${percent1}% , #3264fe ${percent1}% , #3264fe ${percent2}%, #dadae5 ${percent2}%)`;
}

When the input values in the html have value “0” (min=”0″), everything works fine with the fill-color inbetween the dots. But when is set both input to min=”40″ per example,
the percent1 and percent2 variables in the js need to be recalculated. Otherwise the fillcolor between the dots in not correct anymore.

So: what what is the correct calculation for percent1 and percent2 in the js in case min=”20″ or min=”40″ in the html input?

Example 1 with min=”0″: Fiddle 1

Example 2 with min=”40″: Fiddle 2