Slider for comparing images is currently malfunctioning in Firefox

I recently came across a tutorial on how to create an image comparison slider, and it worked flawlessly on Chrome. However, when I tried to load it on Firefox, the slider didn't respond at all.

Below is a snippet of the code:

  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;
}
.wrapper .images .img-2{
  position: absolute;
  height: 100%;
  width: 50%;
  background: url("https://res.cloudinary.com/joanmm/image/upload/v1620035603/CLD/Trommel_original.jpg") 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;
}
... (remaining CSS code)
<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>

Despite inspecting the code with the developer tools, I couldn't find any evident errors that could explain why the slider isn't functioning on Firefox.

Can anyone provide insight into what might be causing this issue?

Answer №1

The reason for this issue is that

<input type="range">
does not have support in Firefox. You may find it beneficial to utilize an alternative approach utilizing the Drag and Drop API.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Aligning a rotated paragraph in the middle of its parent container

Here is my current progress: http://jsfiddle.net/2Zrx7/2/ .events{ height:100px; position: relative; } .tt_username{ position: absolute; top:0px; height: 100%; width: 30px; background: #ccc; text-align: center; } .tt_usern ...

The JavaScript-set value in a form field is not being transmitted to the PHP script within the $_POST array

Struggling to pass a JavaScript value to a .php script, and then on to a .txt script. It works fine with regular numbers, but when trying with the variable it fails, leaving the .txt file blank. Despite extensive research online, I can't seem to get i ...

Create a new variable and compile the sass/less file when it is requested

I'm exploring options to utilize Node.js or another server-side language to handle a specific type of request. For instance, receiving a request like this: The goal is to extract the value from the URL parameter and use it to dynamically update a var ...

What is the best way to ensure the header expands to fill the entire width when zooming out?

When I try to zoom out, the header does not extend to the full width of the page. I have included two images for reference - the first image shows how it should look when zooming out, while the second one depicts the issue where the header does not occupy ...

Tips for saving HTML data locally

Is there a way to persist my HTML element tag data even after the user closes the browser? For example: <div class="classOne" data-random="50"> If I use jQuery to change the data attribute like this: $(".classOne").attr("data-random","40") How ca ...

If the status of any ticket with is_approved=1 is updated to "2", the field ticket_status will be updated based on the order ID in CodeIgniter

This is the table for requests https://i.sstatic.net/NWT4y.png How can I update the ticket_status field with a value of "2" if at least one of the requests has is_approved=1, based on the orderid? I have attempted the following code, but it is not updat ...

What is the best way to integrate varying number formats based on user locale in UI5?

In my SAPUI5 app, I need to display numerical data based on the user's settings in the SU01 backend transaction in SAP Logon. For instance, users can specify decimal separators as: 22,000.000 (twenty two thousand) → US format 22.000,000 (twenty tw ...

Encountering difficulty with displaying a 404 error using Cloud Functions on Firebase Hosting

I am currently facing an issue with handling a custom 404 error using Firebase Hosting and Functions. The code I have provided below works perfectly fine on localhost, but once deployed, Firebase Hosting returns a 500 error instead of the expected 404. ht ...

Enhancing next-auth and i18n functionality with middleware in the latest version of next.js (13) using the app

Currently, I have successfully set up next-auth in my next.js 13 project with app router, and it is functioning as expected. My next step is to incorporate internationalization into my app following the guidelines provided in the next.js documentation. How ...

Struggling to design a functional mobile keyboard

I've been working on creating a mobile keyboard, but I'm facing some issues with the JavaScript part. The problem seems to be in my code as the keyboard isn't responding when I try to type. Here's a snippet of the JavaScript I'm us ...

I want to use flexbox to center three divs on my webpage

I am trying to align 3 divs inside a flex container in the center of the page with equal distance between them and also from the edge of the page. .container { display : flex; width : 60%; } .para { width : 33%; padding : 1em; borde ...

Issues with Bootstrap loading correctly within a Ruby on Rails application

What steps should I take to successfully load Bootstrap 4 on my web app? Here is the contents of my Gemfile: gem 'rails', '~> 5.1.5' gem 'devise' gem 'bootstrap-sass', '~> 3.3.7' gem 'sass-rail ...

Send a string variable from PHP to a JavaScript function

Struggling to transfer a string from a PHP page to a JavaScript function on another page. This is for showing a message after checking if the item being added already exists in an array. I've attempted using quotes and not using quotes in the alert s ...

Preventing default behavior in Firefox using jQuery with event.preventDefault()

Having encountered issues with event.preventDefault() specifically in Firefox, I noticed that the jQuery code included below is not functioning as intended. $("#facebook-del-1").click(function(){ event.preventDefault(); var selector = "#"+$(this).attr("id ...

Preserve the output from the jQuery ajax request

I have created a custom function that calls an ajax request and saves the response data to a variable before returning it. It always shows '0' as the return value, but the alert displays numbers like 3712. Below is the implementation of the func ...

Tips for extracting data from arrays with multiple dimensions - (JavaScript)

I am looking to extract string values from a multi-dimensional array and store them in a new array as the answer. For Example : var dimStr = [ "First-one", ["Double-one", "Double-two", "Double-three", ["Triple-one", "Triple-two"] ], "First-two" ] ; The ...

Issues with AngularJS Directives not functioning properly when elements are added dynamically through an AJAX request

I am facing a scenario where I have a page featuring a modal window that is created using the AngularUI Bootstrap modal directive. The DOM structure for this modal is being dynamically loaded from the server, and it is triggered to open when a specific but ...

Is there a method in JavaScript/jQuery to gently push or flick the scroll so that it can be easily interrupted by the user? Further details are provided below

I am looking for a solution in javascript that will allow the page to automatically scroll down slightly, but I also want the user to be able to interrupt this scroll. When using jquery for auto-scrolling, if the user begins manual scrolling while the ani ...

What action is initiated when the save button is clicked in ckEditor?

Incorporating a ckeditor editor into my asp.net application has been successful. At this point, I am looking to identify the event that is fired by ckeditor when the save button in the toolbar is clicked. Has anyone come across this information? ...

Creating an empty array within an object in JavaScript

Consider the following scenario: var form = { header: { value: null, isValid: false, type: 'textinput', rules: { isRequired: true, ...