Angular: identifying inconsistencies between previous and current values with range slider and numeric input spinner

Attempting to resolve a discrepancy between oldVal and newVal in a 'range slider' and 'number spinner input' that are both linked. Discovered a bug where the difference between oldVal and newVal is much larger than expected, considering the step is set to 5.

The bug becomes evident when binding the slider and spinner, but upon further investigation, the underlying issue with newVal and oldVal becoming apparent: the farther the slider is dragged to the right, the greater the difference.

Here is the approach used to bind the slider & spinner:

var spinnerVal = newVal; 
var newCss = spinnerVal / 100 + "%";
document.querySelector('.range-quantity').style.width = newCss;
document.querySelector('.range-handle').style.left = newCss;

Slider & spinner bound successfully

http://jsfiddle.net/PaulOD/PpCC4/4/

Exploring if there is a more standard method to bind them.

Here is an alternative fiddle where the above code is omitted, resulting in them not being bound to each other. The slider movement is smoother, but the console still shows the discrepancy between oldVal and newVal.

http://jsfiddle.net/PaulOD/PpCC4/5/

Any advice would be greatly appreciated. Also seeking a way to target the slider's true value controls without simply altering the css. Previously used 'ui.value' in jQuery to address these issues effectively, but now attempting to do so without jQuery.

Currently utilizing the powerange slider. EDIT: Bug also replicated with the html range slider here: http://plnkr.co/edit/ke5n3x?p=preview

Thank you, Paul

Answer №1

When observing the difference, it may appear to increase, but in reality, it is dependent on the speed at which the slider is moved. Upon logging newVal - oldVal, the numbers tend to be larger when the slider is moved quickly. However, the values remain consistent across the entire scale, with most results showing either 21 or 64.

This perception might arise from the frequent updates to the value when the slider is moved for an extended period (more than a few milliseconds).

Regarding the implementation of directives:

Instead of relying on the parent scope's value preview.donation, it is recommended to utilize two-way bindings. For more information, refer to this article:

Cheers

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

Tips for validating updates in MongooseEnsuring data integrity is

My current Schema does not validate upon updating. Can you please point out where I went wrong and help me fix it? ...

Endless jasmine timeout

This question is a continuation of a discussion on the Remove timeout for single jasmine spec GitHub issue. Query: Can a single test be configured to never time out? The Issue: While it's possible to set a global timeout value using DEFAULT_TIMEOU ...

How come the HTML page served by the express.js route isn't linked to a CSS stylesheet?

Recently, I've been working with a server.js file that imports a router const path = require("path"); const express = require("express"); const app = express(); const PORT = 8080; app.use(express.urlencoded({ extended: true })); app.use(express.jso ...

When using AngularJS, the ng-class directive displays an expression as a class directly, without first

I'm attempting to create highlighted menu items using AngularJS. After reviewing this particular question and implementing the suggested solution, I encountered an issue where instead of Angular evaluating the expression, it simply displays it as the ...

eachSeries not executing the callback

I am encountering an issue with async.eachSeries. I am using it to loop through an array and download files using a specific function (refer to the source code provided). However, I am having trouble as the callback never seems to be called. Is there somet ...

Achieving the highest ranking for Kendo chart series item labels

Currently, I am working with a Kendo column chart that has multiple series per category. My goal is to position Kendo chart series item labels on top regardless of their value. By default, these labels are placed at the end of each chart item, appearing o ...

Steps for finding a pattern in a list and creating a separate list

Looking to identify a specific pattern in a list retrieved from the service and create a new list with matching items. Below is my code snippet. itemList = itemService.getList(); The itemList comprises of JSON data as shown below. [ { "email ...

Clicking on the button will result in the addition of new

Having some trouble with jQuery as I try to dynamically add and remove HTML elements (on click of +) while also making sure each element has a unique name and ID like "name_1", "name_2"... Unfortunately, things aren't quite going as planned. Below i ...

Serve static assets

Whenever I go to 'http://localhost:8787/article_detail/41', the css and js files are not loading. However, when I visit 'http://localhost:8787/about', all files load correctly. Why is that? app.js app.use(bodyParser.json()); app.use(b ...

Struggling to unlock the mystery of a jammed trigger box

I'm currently working on implementing a small 'trigger box' that will expand upon clicking. It was functional before, but it seems to be encountering an issue now and I'm unsure of the cause. While I have some understanding of HTML and ...

AngularJS shows an error when attempting to access the property 'childNodes' of an undefined element

Recently diving into AngularJS, I incorporated bootstrap validator to ensure form validation in my project. Initially, everything was running smoothly until I introduced the following snippet into my controller's JavaScript file for validation: $(doc ...

Why is the $scope variable value not being updated in Angular JS controller?

My controller code snippet is shown below. I am trying to access the value of $scope.FCGId. How can I access this variable? angular.module('hotelApp.controllers') .controller('menuCtrl', ['$scope','menu' ...

Utilize angular to call a function when navigating

Having an issue with ChartJS while creating a chart using angular. The problem arises when navigating to a new page and then back to the original one, as the JavaScript is not triggered again. Is there a way to automatically invoke a JavaScript function o ...

Handlers for event(s) not triggering on video element

In my NextJS application, I have implemented a feature to display a video file using the video element. I have added multiple event handlers to the video element: <video className='video-player' controls={true} preload='metadata&apo ...

Validation failures frequently occur in the typeahead feature of Angular 2 when using Bootstrap 4, despite a value being selected

I need to implement an auto-complete feature using Bootstrap Typeahead in a form I am currently working on. <input [(ngModel)]="model.brand" [typeahead]="model.brands" ng-model-options="{'updateOn': 'blur'}" (typeaheadOnSele ...

Generate an asynchronous boolean promise when calling the isPresent function in Protractor

I'm currently working on a function that checks the presence of an element and returns a boolean value accordingly. However, I am facing an issue where the response includes unnecessary information. the output displays: false How can I adjust my cod ...

Testing the ui-router with an incorrect route for unit testing

After finding a helpful post on Stack Overflow about adding unit tests for ui-router, I decided to implement the following test: describe 'State: myApp', -> # Loading the module of the filter beforeEach module 'myApp' $rootS ...

What occurs when the state of a DOM element is altered?

I've come across a few articles discussing the Real DOM and Virtual DOM, but I'm still finding it difficult to grasp the concept fully. When updating an element on a webpage, does the browser render the entire page or just the specific part bein ...

Creating a test suite with Jasmine for an Angular ui-grid component compiled without using $scope

I have encountered an issue while using $compile to compile a ui-grid for Jasmine testing. Initially, everything worked smoothly when I passed $scope as a parameter to the controller. However, I am now transitioning to using vm, which has resulted in $comp ...

After the build process, Nextjs Sitemap is eliminating the /en/ from all newly generated web links

Utilizing Strapi to pull data in JSON format. For instance, a typical website link appears as follows: https:/ /www.some-site.com/some-link What happens to the links once the post build is completed on my Nextjs project: <url><loc>https://web ...