图像比较滑块在 Firefox 上不起作用

Image comparison slider not working on Firefox

我发现 this tutorial 创建了一个图像比较滑块,它在 Chrome 上完美运行。但是,当我在 Firefox 上加载它时,滑块根本没有反应。

举个例子:

  const slider = document.querySelector(".slider input");
  const img = document.querySelector(".images .img-2");
  const dragLine = document.querySelector(".slider .drag-line");
  slider.oninput = ()=>{
    let sliderVal = slider.value;
    dragLine.style.left = sliderVal + "%";
    img.style.width = sliderVal + "%";
  }
    *{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,body{
  /* display: grid; */
  height: 100%;
  place-items: center;
  background: #efefef;
}
.wrapper{
  position: relative;
  height: 600px;
  width: 743px;
  overflow: hidden;
  background: #fff;
  border: 7px solid #fff;
  box-shadow: 0px 0px 15px rgba(0,0,0,0.15);
  margin: auto;
}
.wrapper .images{
  height: 100%;
  width: 100%;
  display: flex;
}
.wrapper .images .img-1{
  height: 100%;
  width: 100%;
  background: url("https://res.cloudinary.com/joanmm/image/upload/v1620035713/CLD/Trommel_digital.png") no-repeat;
  /* background: url("images/car.jpg") no-repeat; */
}
.wrapper .images .img-2{
  position: absolute;
  height: 100%;
  width: 50%;
  /* filter: blur(5px); */
  background: url("https://res.cloudinary.com/joanmm/image/upload/v1620035603/CLD/Trommel_original.jpg") no-repeat;
  /* background: url("images/car.png") no-repeat; */
}
.wrapper .slider{
  position: absolute;
  top: 0;
  width: 100%;
  z-index: 99;
}
.wrapper .slider input{
  width: 100%;
  outline: none;
  background: none;
  -webkit-appearance: none;
}
.slider input::-webkit-slider-thumb{
  height: 586px;
  width: 3px;
  background: none;
  -webkit-appearance: none;
  cursor: col-resize;
}
.slider .drag-line{
  width: 3px;
  height: 586px;
  position: absolute;
  left: 49.85%;
  pointer-events: none;
}
.slider .drag-line::before,
.slider .drag-line::after{
  position: absolute;
  content: "";
  width: 100%;
  height: 273px;
  background: #fff;
}
.slider .drag-line::before{
  top: 0;
}
.slider .drag-line::after{
  bottom: 0;
}
.slider .drag-line span{
  height: 42px;
  width: 42px;
  border: 3px solid #fff;
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.slider .drag-line span::before,
.slider .drag-line span::after{
  position: absolute;
  content: "";
  top: 50%;
  border: 10px solid transparent;
  border-bottom-width: 0px;
  border-right-width: 0px;
  transform: translate(-50%, -50%) rotate(45deg);
}
.slider .drag-line span::before{
  left: 40%;
  border-left-color: #fff;
}
.slider .drag-line span::after{
  left: 60%;
  border-top-color: #fff;
}
<div class="wrapper">
  <div class="images">
    <div class="img-1"></div>
    <div class="img-2"></div>
  </div>
  <div class="slider">
    <div class="drag-line">
      <span></span>
    </div>
    <input type="range" min="0" max="100" value="50">
  </div>
</div>

我无法使用检查器工具识别任何相关的错误检查。

知道问题出在哪里吗?

那是因为<input type="range"> is not supported by Firefox. You might prefer using a solution based on the Drag and drop API