This template should help get you started developing with Vue 3 in Vite.
VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).
See Vite Configuration Reference.
npm install
npm run dev
npm run build
Custom range slider built with Vue 3
Home Page: https://custom-vue-range-slider.netlify.app/
This template should help get you started developing with Vue 3 in Vite.
VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).
See Vite Configuration Reference.
npm install
npm run dev
npm run build
Hi - I came across your component shared on a blog and I was planning to use something similar.
Currently, I do not see validations ensuring slider max is always greater than slider min - or in other words preventing to slider min to be more than slider max.
Were you planning to add it to your component by any chance ? @miracleonyenma
Hi, please check your css code in the firefox browser, it is not displayed correctly and dragging sliders does not work
I would like to report a couple of issues in function onInput
in following file:
const onInputMin = ({ target }) => { //
}
const onInputMax = ({ target }) => { //
}
target.value > sliderMaxValue.value ? target.value = sliderMaxValue.value : sliderMinValue.value = parseFloat(target.value);
per my understanding, it should not be a default behavior anyways even if it should be possible to do. The value of the opposing slider should be x +- 1
. For min slider the value should be max slider -1, for max slider the minimum value should be min slier value +1.
target.value >= sliderMaxValue.value // see >=
? target.value = sliderMaxValue.value - 1 // see - 1 (for the other slider we set the +1
: sliderMinValue.value = parseFloat(target.value);
ideally it should be:
if (target.value >= sliderMaxValue.value){
target.value = sliderMaxValue.value - 1
}
sliderMinValue.value = parseFloat(target.value); // always set the value! no ELSE!
parseFloat
, not sure if this should be reported as a "problem", but I could not think of a use-case for this. The value is always returned as the integer. isn't it so? So at what point do we need to have a floating point conversion? This is the second performance concern. It should not influence the logic in any way.Regardless if you agree with all suggested edits and proposals or not, here is the version of the code that I am using for my needs:
const onInputMin = ({ target }) => {
if (target.value >= sliderMaxValue.value) {
target.value = sliderMaxValue.value - 1
}
sliderMinValue.value = target.value
}
const onInputMax = ({ target }) => {
if (target.value <= sliderMinValue.value) {
target.value = sliderMinValue.value + 1
}
sliderMaxValue.value = target.value
}
Thank you very much for your solution! it works much faster than hand-made divs that act like range sliders. Soon as I added 2000 of range sliders your solution works just almost as good as 1 range slider. Whereas the custom made slider is laggy as hell and wants to obliterate my PC every second :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.