Giter Site home page Giter Site logo

Comments (3)

sghall avatar sghall commented on June 15, 2024 1

Hey there, sure, if I understand correctly, you can just use a custom mode. Just pass a function for the mode prop.

Here's a sandbox...
https://codesandbox.io/s/9z462x453w

        const domain = [10, 100];
        const defaultValues = [10];
        const validValues = [10, 24, 40, 100];

        ...

        <Slider
          mode={(curr, next) => { // custom mode 
            if (validValues.indexOf(next[0].val) !== -1) {
              return next;
            }

            return curr;
          }}
          step={2}
          domain={domain}
          rootStyle={sliderStyle}
          onUpdate={this.onUpdate}
          onChange={this.onChange}
          values={defaultValues}
        >

The custom mode function receives curr and next which are arrays of { key, val } objects. One item for each handle in the slider.

The built in modes look like this...
https://github.com/sghall/react-compound-slider/blob/master/src/Slider/modes.js

from react-compound-slider.

sghall avatar sghall commented on June 15, 2024

Alternatively, you can keep the options evenly spaced and format the ticks:
https://codesandbox.io/s/oy7m6wpjq

from react-compound-slider.

Kaylen-Pillay avatar Kaylen-Pillay commented on June 15, 2024

Thank you so much for that explanation. I'm going to be working through this today, this is an AMAZING library

from react-compound-slider.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.