"Exploring the Power of Logarithmic Slider with Vue and Quasar

I'm currently working on a project utilizing Vue 2 and Quasar 1, where I am attempting to develop a logarithmic slider. Initially, I managed to create a basic example using a native input slider in this code pen: https://codepen.io/tonycarpenter/pen/ZEVKWbr?editors=1111

function calculateLogarithmicSlider(min, max, sliderPosition) {
  const minimumSliderValue = Math.log(min);
  const maximumSliderValue = Math.log(max);
  const sliderScale = (maximumSliderValue-minimumSliderValue) / (100);
  return Math.exp(minimumSliderValue + sliderScale*(sliderPosition));
}

function calculateSliderValue (min, max, sliderPosition) {
    return Math.round(calculateLogarithmicSlider(min, max, sliderPosition));
}

const smartRange = {
    props: ['min', 'max'],
    template:
`
    <div>
        <label> MIN: {{ min }} MAX: {{ max }} <label>
        <input v-on:input='update($event)' type='range'>
    </div>
`,
    methods: {
        update(event) {
            const sliderPosition = parseInt(event.target.value)            
            const sliderValue = calculateSliderValue(this.min, this.max, sliderPosition)
            this.$emit('change', sliderValue)
        }
    }
}


const app = new Vue({
    el: document.querySelector('#app'),
    components: { smartRange },
    data: {
        value: 0
    },
    methods: {
        updateVal(newVal) { this.value = newVal }
    }
})

My current challenge involves binding this logic to a Quasar slider with an accompanying tooltip that reflects the exponential increase while sliding. I have provided a link to the specific Quasar slider implementation below: https://codepen.io/tonycarpenter/pen/bGOWXKG

While researching solutions online, I stumbled upon one that uses a Quasar range slider with Vue 3 and Quasar 2. However, I would appreciate further clarification as I am not well-versed in Vue 2 compared to Vue 3: https://codepen.io/pdanpdan/pen/XWYPZMq?editors=1111

Any assistance or guidance in this matter would be immensely valuable!

Answer №1

I've created a custom slider for you, feel free to check it out here:

https://codepen.io/prince_61/pen/ZEVyQBQ

<div id="q-app" style="min-height: 100vh;">
  <div class="q-pa-md">
    <q-badge color="secondary">
      Model: {{ redModel }} (0 to 100, step 100)
    </q-badge>
    <q-slider
      v-model="redModel"
      color="red"
      :step="1"
    ></q-slider>
  </div>
</div>
const { ref } = Vue

const app = Vue.createApp({
  setup () {
    return {
      redModel: ref(25),
    }
  }
})

app.use(Quasar, { config: {} })
app.mount('#q-app')

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

Instructions on adjusting the image size within a MUI Card

import { Card, CardActionArea, CardContent, CardMedia, Typography, } from "@mui/material"; import React from "react"; import { styled } from "@mui/material/styles"; const CardImage = styled("div")(({ theme ...

Events in d3.js are properly registered, however they are not being triggered as

After creating an enter section that transitions to set the opacity to 1, I encountered an issue where the 'click' event on the circle worked but not on the text. Interestingly, when I replaced the 'text' with a 'rect' and se ...

Implementing Laravel's functionality for calculating average ratings with the help of jQuery

In my database, I have two tables named Users and ratings. The Users can give ratings to consultants, and the Ratings table structure is as follows: User_id | consultant_id | rating --------------------------------- 1 1 2 ...

Executing function after completion of ajax call

I have 2 buttons and 3 links that trigger an ajax request. I want to display an alert only when the request initiated by one of the buttons is completed, but not when a link is clicked. Below is my code: HTML: <button id="ajax1">Ajax 1</button&g ...

Trouble retrieving data using component props

I am currently facing an issue with displaying data from the API in a component. The request is being made from the parent page, but the loop to display the data is within the child component. Unfortunately, the data is not showing up on the parent page as ...

Listcell XUL with button options

How can I make buttons inside a listcell function in XUL? I am having trouble getting it to work. Here is the XUL code: <listitem id = "1"> <listcell label = "OK Computer"/> <listcell label = "Radiohead"/> <listcell label ...

How can I search multiple columns in Supabase using JavaScript for full text search functionality?

I've experimented with various symbols in an attempt to separate columns, such as ||, |, &&, and & with different spacing variations. For example .textSearch("username, title, description", "..."); .textSearch("username|title|description", "..."); U ...

I'm currently utilizing lint in my Angular 2+ project. Is there a way to arrange the constructor parameters in alphabetical order

I am struggling to organize the constructor parameters in TypeScript while using TSLINT with Angular9. I am looking for a rule similar to member-ordering that can help me sort them effectively. constructor( // Sort these private readonly router: R ...

Managing data flow in React and Reflux: Utilizing a single component duplicated in the DOM

Imagine this Tree scenario: <Homepage> <HeaderSection> <Navbar> <ShoppingCartComponent> </Navbar> </HeaderSection> <MainContent> <ShoppingCartComponent> &l ...

Implementing Vuex to dynamically update an object's array property by pushing new elements inside a mutation with reactivity

As per the Official documentation, vuex mutations have certain limitations when it comes to reactivity. When we need to add a new property to an object, we usually use: Vue.set(obj, 'newProp', 123) However, adding a new array property and push ...

Sinon respects my intern functions during testing in ExpressJS

At the moment, I am working on incorporating sinon stubs into my express routes. However, I am facing an issue where my functions are not being replaced as expected. I would like my test to send a request to my login route and have it call a fake function ...

Submit button on Ajax form causes automatic page refresh

After adding a simple Ajax form to my WordPress website, I encountered an issue where the validation works fine, but instead of sending the email, the form refreshes after submitting. Here is the code snippet: <script type="text/javascript"> jQ ...

What are the steps to correctly implement async await in a standard sequence?

When I press the button onPress={() => Login()} First, I need to obtain a token by using the signInWithKakao function. Secondly, right after acquiring the token, if it is available, I want to dispatch the profile using the kakaoprofile function. However, ...

Can Comet be implemented without utilizing PrototypeJs?

Can Comet be implemented without utilizing PrototypeJs? ...

Trouble with CSS and JS tabs not activating when clicked?

I am experiencing issues with a navigation (organized in tabs) that is not functioning on this page, but it works correctly on this page using the same method for inclusion. When clicking "Norway" on the top left, the navigation opens but switching to the ...

Effective methods for transferring parameters between two separate JavaScript files within an express.js application

Currently, I am working with Express.js and facing a challenge in passing parameters from one JavaScript file to another. How can this be accomplished? The two files involved are 1. process.js var WebPageTest = require('webpagetest'); var wpt ...

Enhance your AngularJS skills by incorporating multiple conditions into the ternary operations of ng-class

I am struggling to apply multiple classes when the condition in the ng-class attribute evaluates to true. Here is the code I have attempted so far, but it doesn't seem to be working: <div class="col-md-4" ng-mouseover="hoverButton=true" id="plai ...

Guide to integrating Webpack 3.8.1 into a Vue application

So I have this scaffold: https://github.com/vuejs/vue-cli Now, my goal is to integrate Webpack 3.8.1 into it. There's an existing "build" folder with numerous webpack files in it : https://i.stack.imgur.com/MJ3JP.png However, when I try running "w ...

Seeking assistance with setting up BxSlider installation

I'm struggling with adding bxslider to my HTML template. No matter what I try, the slider doesn't work as expected. When I preview my website, all three images are displayed together in a single column. Can someone please guide me on how to fix t ...

Can JSON be used to perform mathematical operations and calculations?

Utilizing the amazing json-server as my application's backend has been incredibly beneficial for custom data retrieval. However, it would be even more valuable if it supported calculations and expressions to mimic backend behavior. Consider this data ...