Updating the IonRange Slider with transition动🔘

I came across a plugin called ionRange slider and found a demo of it here.

Currently, I am trying to incorporate a transition onUpdate. I have already included transitions in both the slider handle and bar using CSS code:

.irs--big .irs-handle {
    transition: all ease .2s;
}
.irs--big .irs-bar--single {
    transition: all ease .2s;
}

Unfortunately, the transitions only seem to work on the onChange event, not onUpdate.

When onUpdate is triggered, the value abruptly changes without any transitional effects.

Answer â„–1

What's happening in this scenario is that the onUpdate event is removing the entire slider from the DOM and replacing it with a new one containing updated values. It appears that you are retrieving these new values from some form of input, such as a user entering a price into a field and submitting it for use in updating the slider.

There are several approaches we can take to achieve your desired outcome. First, we could directly edit the plugin's JavaScript files, but this would require extensive work and forego the benefits of using the free CDN they provide. Second, we could update the slider with the old values and then manually adjust its position using JavaScript. Finally, we could disregard the onUpdate event altogether and create our own custom CustomUpdate event. So...

$("#input").click(function(){  
//$("#ion-slider").update();   Don't do this!!!  
$("#ion-slider").trigger("customUpdate"); //Do this instead
})

$("#input").on( "customUpdate", function(){      
  var calib = "someNumericInputWidthRatio"; //set a value like 34
  var newWidth = calib*$("input").value();
  $("irs-bar.irs-bar--single").width(newWidth); //this will smoothly transition with CSS transitions
 $(".irs-handle.single").left(newWidth+15); // 15 represents half of the draggable circle's width
})

Remember to append "px" to the numeric widths where necessary, as I've been somewhat careless. The main goal here is to convey the concept through jQuery-like pseudo code.

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

What is the process for setting `name` and `inheritAttrs` within the `<script setup>` tag?

Options API: <script> import { defineComponent } from 'vue' export default defineComponent({ name: 'CustomName', // ...

Material Design Angular2 Toolbar

I am currently working on designing a toolbar using Material and Angular2. My main challenge is formatting the toolbar in such a way that the search bar appears centered in white, while the "Create Project" button and other buttons are aligned to the right ...

Unexpected jQuery error: Uncaught TypeError - Invocation not allowed

Yesterday, the code was functioning perfectly, but today it suddenly started throwing an error: Uncaught TypeError: Illegal invocation I'm struggling to pinpoint where exactly the issue lies. function createFile() { var selected_retailer_uui ...

I am struggling to activate the hovering feature on my menu bar

I am having trouble making the hover effect in my navigation bar work properly. Even though I can separately make the 'display: none' and hover effects work, they do not function together. I am unsure of what mistake I might be making. Below is ...

Is it possible to deinitialize data tables (remove from memory)?

I'm currently utilizing data-tables (with jQuery) on my website. The particular data-table I have implemented seems to be consuming excessive memory in javascript, causing a slowdown in other functionalities. Is there a way for me to de-initialize th ...

Encountered an error while attempting to log in: TypeError: the property 'id' of null cannot be read

I am facing an issue with the login process, specifically getting a TypeError: Cannot read property 'id' of null error message. How can I debug and resolve this error? var cas = require('cas-client'); get_forward_url(function(forwardur ...

Guide on navigating an array of objects using the provided keys as a starting point in Javascript/Typescript

Assuming I have an array of objects structured like this: const events: Array<{year: number, month: number, date: number}> = [ {year: 2020, month: 10, date: 13}, {year: 2021: month: 3, date: 12}, {year: 2021: month: 9, date: 6}, {year: 2021: mont ...

save the state of the store navigation panel when the toggler is clicked

I'm currently working on a Bootstrap website with a navigation panel located on the left side. There is a toggler for this navigation panel, <div class="sidebar-toggler"> </div> By clicking on the toggler, it hides the navigation pane an ...

Getting EdgesHelper to align properly with Mesh in Three.js

Within a dynamic scene, multiple mesh objects (specifically cubes) have been included. A unique EdgeHelper has been generated for each cube to track its movements and rotations. Whenever a particular cube mesh is selected, I am aiming to alter the color o ...

When a button is clicked, unleash the magic of music using JavaScript

Why isn't the button onclick working for the mp3 file I uploaded to GitHub? I even tried using the link through https://voca.ro/1dcHxW3v1oQA, but it still wouldn't work. function play() { var audio = new ...

Is there a way to make the background transition colors on scroll for a Tumblr theme

Currently, I am utilizing a Tumblr theme that scrolls horizontally. You can find the theme here. Does anyone have recommendations on how to change the background to red while scrolling and then switch back to white when scrolling stops? This is the CSS c ...

Organizing a JSON array and displaying it using the $.each function

My JSON array is structured like this: "series": [{ "book": 1, "chapter": 1, "title": "Title of this chapter", }, { "book": 1, "chapter": 2, "title": "Title of this chapter", }, { "bo ...

Text hidden within the image, each line concealing a separate message

I am having an issue where my image is overlaying the text. I would like the text to wrap around the image and for any hidden text to appear on a different line. How can this be achieved? Here is the CSS code I am using: div.relative { position: relati ...

delay in displaying options when toggling visibility in a dropdown menu

When you first click on the select, it displays incorrectly https://i.sstatic.net/Ax9T7j8J.png But when you click on it a second time, it displays correctly https://i.sstatic.net/UpW4krED.png $(document).on("click", "#edit_afpDetalle_mes&q ...

What could be causing the HTML element to be invisible on Internet Explorer?

I am currently working on my angularjs project. One of the features I have implemented is an HTML view that switches between display mode and edit mode when a button is clicked. To style this functionality, I created a CSS class called edit-mode. You ca ...

Having issues with the toggle display button functionality not working properly in Angular when using click()

One of the files in my project is named server.component.ts and another is named server.component.html. This is how my server.component.ts file is structured: import { Component } from '@angular/core'; @Component({ selector: 'app-server& ...

What is the best way to contain the CSS for dynamically generated HTML within a div element without impacting other elements on the page?

I am currently facing a challenge where users can input any HTML into a text box, and I need to manipulate that HTML by identifying elements such as anchor tags or divs. To achieve this, I have created a hidden div and copied the pasted HTML into it using ...

Mastering the art of using the async pipe in conjunction with rxjs

I require assistance as the loading component of my async pipe does not activate, despite the data loading correctly. The loading template fails to trigger during subscription even though I am using a BehaviorSubject in my service. I have attempted various ...

Creating registration and login forms using an express server

Currently, I'm in the process of creating a basic website on my localhost that incorporates a signup form along with other essential HTML elements. The setup for the signup procedure went smoothly as planned. When a user completes the form and submits ...

Tips for seamless integration of Crashlytics with your React Native application

As I work on developing my app with React Native, I am looking to capture crashes that occur on both the Objective-C and JavaScript aspects of the application. After following Crashlytics SDK's installation guide, I successfully implemented it into m ...