Code Monkey home page Code Monkey logo

svelte-range-slider-pips's Introduction

Svelte Range Slider Logo

Svelte Range Slider (with pips)

Code Version NPM version NPM Downloads / Month

A reactive, accessible, multi-thumb, range slider with the ability to display "pips" or "notches" along the range.
Importable as a svelte-component, or able to be used directly in any javascript application / framework.

Svelte Range Slider; focussed with pips and labels prop set

๐Ÿ“”๐Ÿ” Docs Full Documentation & Examples
๐Ÿ“โš™ REPL Svelte component demo
โคโœ’ Codepen Plain JS component demo


Features

Features of the range slider plugin (written below)

  • โœจ fully customisable, stylable & accessible
  • ๐Ÿ‘๐Ÿฝ multi-thumb
  • ๐ŸŽš range (min/max)
  • ๐Ÿท floating labels
  • ๐Ÿ“ ruler notches
  • ๐Ÿท labels for notches
  • ๐Ÿงฎ step function
  • ๐Ÿ– formatter
  • ๐ŸŽญ animated

Install

Open your project and use the command line to install the package;

yarn add svelte-range-slider-pips --dev          # or
npm install svelte-range-slider-pips --save-dev  # if you prefer npm

Usage

In a svelte project

Assuming you have a Svelte app up and running;

<script>
  import RangeSlider from "svelte-range-slider-pips";
</script>

<RangeSlider values={[50]} pips />

As a regular JS file

If you're not building a svelte-app, you can use the /dist/ version of the script /dist/svelte-range-slider-pips.js and include it with a regular <script> tag. This should even work with jQuery.

<script src="./js/vendor/svelte-range-slider-pips.js" />

<div id="my-slider"></div>

<script>
  var mySlider = new RangeSliderPips({
    target: document.querySelector("#my-slider"),
    props: { values: [50], pips: true }
  });
</script>

As a JS module

If you're building a bleeding-edge JS application (maybe Vue or React), you might want to use js imports (import)

import RangeSlider from "./node_modules/svelte-range-slider-pips/dist/svelte-range-slider-pips.mjs";

var mySlider = new RangeSlider({
  target: node, // js reference to a DOM element
  props: { values: [50], pips: true }
});


Props (options)

Slider props

prop type default description
values Array [50] Array of values to apply on the slider. Multiple values creates multiple handles. (note: A slider with range property set can only have two values max)
min Number 0 Minimum value for the slider (should be < max)
max Number 100 Maximum value for the slider (should be > min)
step Number 1 Every nth value to allow handle to stop at (should be a positive value)
range Boolean/String false Whether to style as a range picker. Use range='min' or range='max' for min/max variants
pushy Boolean false If range is true, then this boolean decides if one handle will push the other along
float Boolean false Set true to add a floating label above focussed handles
vertical Boolean false Make the slider render vertically (lower value on bottom)
pips Boolean false Whether to show pips/notches on the slider
pipstep Number 1/10/20 Every nth step to show a pip for. This has multiple defaults depending on values property
first Boolean/String false Whether to show a pip or label for the first value on slider. Use first='label' to show a label value
last Boolean/String false Whether to show a pip or label for the last value on slider. Use last='label' to show a label value
rest Boolean/String false Whether to show a pip or label for all other values. Use rest='label' to show a label value
all Boolean/String false Whether to show a pip or label for all values. Same as combining first, last and rest. Use all='label' to show a label value
prefix String "" A string to prefix to all displayed values
suffix String "" A string to suffix to all displayed values
reversed Boolean false Reverse the orientation of min/max
hoverable Boolean true Whether hover styles are enabled for both handles and pips/values
disabled Boolean false Determine if the slider is disabled, or enabled (only disables interactions, and events)
id String "" Give the slider a unique ID for use in styling
ariaLabels Array [] Array of strings to use for the aria-label attribute on the handles.
formatter Function (v,i,p) => v A function to re-format values before they are displayed (v = value, i = pip index, p = percent)
handleFormatter Function formatter A function to re-format values on the handle/float before they are displayed. Defaults to the same function given to the formatter property (v = value, i = handle index, p = percent)
springValues Object { stiffness: 0.15, damping: 0.4 } Svelte spring physics object to change the behaviour of the handle when moving
slider Element undefined DOM reference for binding to the main <div /> of the component (bind:slider='ref')

๐Ÿ“”๐Ÿ” | Documentation for Options

Slider events (dispatched)

event example event.detail description
start on:start={(e) => { ... }} { activeHandle: Integer, value: Float, values: Array } Event fired when the user begins interaction with the slider
change on:change={(e) => { ... }} { activeHandle: Integer, startValue: Float, previousValue: Float, value: Float, values: Array } Event fired when the user changes the value; returns the previous value, also
stop on:stop={(e) => { ... }} { activeHandle: Integer, startValue: Float, value: Float, values: Array } Event fired when the user stops interacting with slider; returns the beginning value, also

๐Ÿ“”๐Ÿ” | Documentation for Events



Styling

Styling should mostly be done with CSS.
There's a bunch of css variables for controlling the colors of the elements. And the slider is fluid horizontally, with the size of things controlled by font-size. So you may change the font-size on the .rangeSlider base element to change the scale of everything.

If you require more fine control of the widths, heights, etc, then you may override the default css. This can be easier by using the id prop to give your slider a unique id.

Values of labels can be styled with CSS, and the format can be modified with the formatter() function prop. And animation of the handles is controlled by the springValues object prop.

๐Ÿ“”๐Ÿ” | Documentation for Styling



Contribute

I am very happy to accept;

  • ๐ŸŒŸ suggestions/requests for new features or changes
  • ๐Ÿ›  pull-requests for bug fixes, or issue resolution
  • ๐Ÿงช help with creating a proper test-suite

Read the CONTRIBUTING.md


Support / Donate

I'd be super excited if you find this project useful and wish to donate a small amount for my efforts!

ยฃ1 One Pound Donation ยฃ1 GBP donation
ยฃ5 Five Pounds Donation ยฃ5 GBP donation
ยฃ10 Ten Pounds Donation ยฃ10 GBP donation

svelte-range-slider-pips's People

Contributors

acurrieclark avatar dependabot[bot] avatar janosh avatar mathieu-cosyns avatar mivermeu avatar rbrdl avatar satanskitty avatar simeydotme avatar zqianem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

svelte-range-slider-pips's Issues

FR: Custom Positioning of PIPS...

The PIPS seem to only be able to be even distributed, but I would like the ability to timestamp the slider at specific points. The use case would be an audio or video slider where I can mark where the Chorus happens, for example, like so:

song-slider-example

...it would also be cool for people to be able to click on the song position dots and jump right to that point in the music as well :-)

[bug] 'selected' CSS property not working properly with float steps

Description:
When using a step size of 0.05, and setting min/max to 0/1 respectively, the pips do not consistently get the 'selected' property applied.
This seems to have to do with their values suffering from floating point inaccuracies (0.6000000003 instead of 0.6).

Reproduced in REPL:
https://svelte.dev/repl/d5a08fc50b3d4f6cb23423be7fdbb976?version=3.46.4

Steps to reproduce the behavior:

  1. Move the Slider.
  2. Observe the label, only shown on the 'selected' pip.
  3. Alternatively, use Browser Inspection Tool to check CSS properties.

Expected behavior:
The selected pip should get the 'selected' property.

Possible Fix:
Determine 'selected' pip by choosing nearest one to the actual value, or allow deviation instead of checking for exact equality.

preventDefault on the click event

Hello,

Thank you very much for this very well designed component !

I have an issue with its integration inside a "popover" UI component. I have an event handler that close the "popover" when we click outside of it : https://svelte.dev/repl/802bb20faafc4256a0abc0afcba4cd46?version=3.31.0. In the REPL, if you start the interaction by clicking on the slider and finish it outside of the popover, the popover will be immediately closed wich is not what we want here.

The technical solution would be to call event.preventDefault in the slider handler, but I'm not sure how to do that. Maybe it could also be called by default? (not sure of the implications?

Uniquely styling multiple handles

We're using this component in p5-svelte's docs to change x and y dimensions of a sketch and would like to be able to independently label each based on their index respective to the passed-in values array:

image

So that we could have two thumbs with the format: x: ..., y: ...

Explicitly Document how to bind:values, and why it's an Array

currently I am trying to:

bind:values={[$volume]}

...but I get the following error:

Can only bind to an identifier (e.g. `foo`) or a member expression (e.g. `foo.bar` or `foo[baz]`) (59:3)

...and I honestly only need one value for my use cases (volume slider and timeline, which you have expressed reservations about :-)

so, would it be possible to add a value prop that only takes one number? or is there a way for binding to work with the values prop?

REPL for reference:

https://svelte.dev/repl/9e6d515b510143e4b1b8a7a01940f0db?version=3.29.6

the issue is in the Player.svelte file on line 59.

Thanks a bunch!

[question] Pips above slider

Thanks for making this component!

I'm implementing a design where the pips/labels are above instead of below the slider. Which is a bit unusual, but makes sense in the context.

Screen Shot 2022-09-09 at 8 02 07 PM

From quickly testing I seem to be able to achieve this with css only by setting negative values to the absolute position attributes of .rangePips and .pipVal then tweaking some other things as well.

So before going down this path, I just wanted to know, if I missed something in the docs and if there is a better way to do this.

Changing Values Dynamically

Hi, I am trying to integrate this package in react application. How can the values be changed dynamically ?

Click pip or label to select value

This is halfway between a bug report and feature request. Currently, clicking on pips or labels is the same as clicking on the actual slider at that pixel. This means that clicking on labels will often give inaccurate results for continuous sliders or sliders with small step values. Click the "30" label in this REPL example to see what I mean.
https://svelte.dev/repl/fefe88d5a0574258837318c9db46bc63?version=3

Depending on exactly where you clicked you might get any value between 28 and 32. I'd expect clicking on labels to set the slider to exactly that value. Then you'd have the best of both worlds: the free range of a continuous slider with some easy clickable shortcuts to set frequently used exact values (e.g. zoom to 50% and 100%).

For extra brownie points, highlight the labels on hover (see mockup in the REPL). Thanks for developing such a great component!

[bug] Using the slider for floating point values

Describe the bug
Not sure whether this is a bug or a feature request.

I am trying to use the component to choose a number with decimal point values. However, if I set steps as a decimal value, for example doing the following :

<RangeSlider min="0" max="1" step="0.2" bind:values={sensitivity} float=false pips />

Then I have the error : aligned.toFixed() is not a function.

I know I could probably still use this component and use the formatters to go from 0 to 100 or 0 to 1000 and then format the values by dividing by 100 or 1000, and get the functionnality. However, I was wondering if I was overlooking a cleaner way to go about handling this?

Thanks a lot!

To Reproduce

movable interval

Hi, what a great piece of code :-) really useful!

Would it be possible to add the possibility to move an interval, i.e. not only moving one of the two endpoints, but dragging the line between the endpoints to move the entire range?

Showing Even Labels

Hi, I am using this module in react project. The requirement is to show even years with label [2006,2008,2010.....2020] and odd years with just pips and no label. What is the prop/style config for this?

Issue When Adding a New Value to Values Array

I'm running into an issue when I push a new value to my values array. The thumb for my new value appears at the minimum value of the range slider, regardless of the value. You can grab the thumb and change the value, but the thumb itself doesn't move.

Here is a link to a REPL instance where you can cause the error by hitting the "Add Break" button:
Link

I was able to fix this for my current use case by using a {#key} block and resetting the key any time I modify the array, here's an example:
Link

My fix doesn't seem very good, so built in support for this would be nice.

help with import incantations to test svelte component using RangeSlider with jest

This is almost certainly due to my lack of understanding, but I've been having terrible difficulties trying to test my svelte components using RangeSlider in a node environment with jest. If you have any suggestions or advice, I'd love to hear them. If not, feel free to just close this issue.

My issue is with the (to my mind insane) amount of mystic transpiling required to use either of your published files (.js or .mjs) with jest/node.

My understanding:

  • This project publishes two library files in the npm package:

    • An IIFE: ./dist/svelte-range-slider-pips.js
    • An ES6 module: ./dist/svelte-range-slider-pips.mjs
  • By default, jest requires you to specify experimental options to node in order to use ECMAscript modules (apparently even with node 17).

With the NPM package installed, importing RangeSlider like this works fine in a browser environment:

<script lang= "ts">
  import RangeSlider from "svelte-range-slider-pips";
  ...
</script>

But jest fails to run with TypeError: RangeSlider is not a constructor. My understanding is that this is because the distributed file is an IIFE and not a commonJS exported library/module.

So, next I tried the .mjs file per a hint from the documentation:

<script lang= "ts">
  import RangeSlider from "../../node_modules/svelte-range-slider-pips/dist/svelte-range-slider-pips.mjs";
  ...
</script>

This at least generates a different error (SyntaxError: Unexpected token 'export') and links to the jest documentation linked above.

If I try to run the tests per the jest documentation:

NODE_OPTIONS=--experimental-vm-modules npx jest src/components/SettingsForm.test.js

I get yet a different (but equally mystifying) error message:

Must use import to load ES Module: /Users/rex/Public/repos/ganbarometer-svelte/node_modules/svelte-range-slider-pips/dist/svelte-range-slider-pips.mjs

The only way I've been able to run tests successfully is to copy the .svelte files out of the src/ subdirectory into my build tree directly. This works, and doesn't force me to make source changes from what works in the browser, but, of course, copying files out of node_modules/ breaks npm update and forces me to manually copy again if a new version of the package is published.

None of this seems to be an issue with your code or flexible packaging decisions, but I'm pulling my hair out. I'm posting this in the desperate hope that you might have some advice.

Front-end toolchain stuff hurts my head and breaks my spirit. All these incompatible environments and syntaxes seem bizarre to my "old-school" back-end sensibilities: I've got rollup using at least three different compilers/transpilers on the same source files: svelte, tsc, and babel. Then there's commonJS and ES6 syntax in addition to typescript. Of course I have to consider node vs. browser environments. Oh, did I mention my project needs to be published as a TamperMonkey userscript (IIFE)? How does anyone stay sane?!

[question] TypeError: SvelteRangeSliderPips is not a constructor

Describe the bug
Testing a svelte component that include RangeSlider does not works. I have an error :
TypeError: SvelteRangeSliderPips is not a constructor.

I'm testing a "classic" implementation with :

<script>
  import RangeSlider from "svelte-range-slider-pips";
</script>

<RangeSlider values={[50]} pips />

If I try to fork project and implement some tests with jest and testing library, I don't manage to make it works. Getting error :
Unrecognized option 'sourcemap'.

To Reproduce
Just try to test RangeSlider component in a svelte app.
For the second problem, you can fork : https://github.com/lpoupet/svelte-range-slider-pips

Steps to reproduce the behavior:
Run npm run test

Expected behavior
No error

[feature request] Type Declaration Files for TypeScript

Describe the bug
Upon running yarn run check, a hint is outputted stating the a declaration file for the module could not be found

Steps to reproduce the behavior:

  1. Create a Svelte component and add the following line:
  import RangeSlider from 'svelte-range-slider-pips'
  1. Run the command: yarn run check (svelte-check --tsconfig ./tsconfig.json)

Expected behavior

  • No hint should be displayed
  • A type package, @types/svelte-range-slider-pips, should be made available

Screenshots

Hint: Could not find a declaration file for module 'svelte-range-slider-pips'. '/node_modules/svelte-range-slider-pips/dist/svelte-range-slider-pips.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/svelte-range-slider-pips` if it exists or add a new declaration (.d.ts) file containing `declare module 'svelte-range-slider-pips';` (ts)
  import Fa from 'svelte-fa'
  import RangeSlider from 'svelte-range-slider-pips'

Device/Environtment

Additional context

  • N/A

[bug] Incorrect handling of negative min\max\step values

Hi! First of all, thanks for this stylish and useful component!

Currently there's no any mention in the doc that step value can't be negative, but component allows to do it in some cases. This can result in incorrect slider behavior:

  1. With the min: 0, max: 50, step: -1 props, slider doesn't move smoothly as if step was equal to 1, no any error in the console.
  2. If min: 0, max: 50, step: -1, pips: true, slider does not render at all and throws Uncaught RangeError: Invalid array length

There's no any mention in the doc about min can't be bigger than max, too. At this case, slider renders, but handle can't be moved at all, no errors in the console.

Expected behavior

Implement functional with the proper usage of max < min and step < 0, or handle these cases properly and update the doc.

How can I bind events to the slider handles?

I want to add an on mouseup event to the slider handles. I tried the following but no luck:

<script>
import RangeSlider from "svelte-range-slider-pips";
export let hits = [];
let price;
async function filterOnPrice() {
        index.search('', {
            filters: `price:${price[0]} TO ${price[1]}`,
            facetFilters: 'collections:racefietsen',
        }).then(( res ) => {
            console.log(res);
            hits = res.hits
        });
    }
<script>
<div>
    <RangeSlider range pushy min={0} bind:values={price} on:mouseup={ () => filterOnPrice()} max={5000} float prefix="โ‚ฌ" 
      id="price"/>
</div>

Any tips on how to approach testing components containing RangeSlider?

I have a component which includes svelte-range-slider-pips and binds a value to it.
It applies some transformations too, so it acts as a broker between RangeSlider and a parent component.

I have a testing-library/svelte setup configured for testing and now I'd like to test that interacting with the range slider does actually change the bound value. I imagine the test to look like this:

  1. Render Component with bound value
  2. Find range slider
  3. Interact with range slider
  4. Check that bound value actually changed

I'm a bit stuck at step 3. since I'm not entirely sure how to fire events on range slider so it mimics the user's behaviour.
Any tips on this?

bidirectional Binding input to RangeSlider

The RangeSlider updates the input perfectly. But updating the input field sets everything back to 50. I see that this is related to values being an array. I would guess that most use cases would require a single value.

var value = 50;

<RangeSlider bind:values={value}  />
<input type="number" bind:value  />

Feature Request: Custom PIPS Positions...

The PIPS seem to only be able to be even distributed, but I would like the ability to timestamp the slider at specific points. The use case would be an audio or video slider where I can mark where the Chorus happens, for example, like so:

song-slider-example

...it would also be cool for people to be able to click on the song position dots and jump right to that point in the music as well :-)

Moving Transition for value indicator

Hi @simeydotme , Is it possible to add a transition while the value changes from one to other. For example i am using this for a racce chart and the value changes when the chart moves, so i need to move the indicator between two values.

image

As seen in the image the value will be 2016 initially and then it changes to 2017 as chart moves, currently the value indicator moves once from 2016 to 2017 but i need to move the value indicator slowly towards 2017 as value changes. Is it possible ?

Issue while running npm run build

Error Shown

Name expected [../node_modules/svelte-range-slider-pips/dist/svelte-range-slider-pips.mjs:22,0]

This is the import i used in my component:
import RangeSlider from "svelte-range-slider-pips";

What is the reason for this error and how to fix this ?

[bug] Svelte warns about a missing `slider` prop

Describe the bug

When an instance of the RangeSlider is created without specifying the slider prop, Svelte displays the following warning in the JavaScript console : <RangeSlider> was created without expected prop 'slider'.

To Reproduce

Expected behavior

As the slider prop is not mandatory, there should be no warning.

Possible solution

Set the slider prop to undefined by default?

// dom references
export let slider = undefined;

[bug] Apparent no-reason glitch in slider among multiple ones

Describe the bug
I have two sliders with float, pips and labels. One of them works perfectly, and the other one doesn't: it jiggles too much and sticks to the end franticly while you slide it, making it really hard to select a value.

To Reproduce

The project's repository: https://github.com/Pierstoval/handpan-svelte/
It is hosted on Github Pages there: https://pierstoval.github.io/handpan-svelte/

Move the "Speed (bpm)" slider to reproduce.

Screenshots

See:
Animation

Device/Environment

svelte-range-slider-pips version: 1.8.0

Tested on Windows 10 Pro, with Firefox 90.0.2 and Brave 1.27.109 (uses Chromium: 92.0.4515.115).

Additional context

Here's the code: <RangeSlider min={Track.MIN_BPM} max={Track.MAX_BPM} step=5 float pips pipstep=2 all="label" /> (the Track class comes from the project's Typescript sources)

I have tried several solutions, like removing bound variables, changing min/max/step/pipstep, removing the other slider... None worked.

What am I doing wrong?

ValidationError when compiling

Hi.

There is an error compiling the code. I think it's because of the new version of svelte. Yesterday the component was good for me and today it doesn't, the only change that has been made has been to update the version of svelte.

You could separate the :global in two?

ERROR in ./node_modules/svelte-range-slider-pips/src/RangeSlider.svelte
Module build failed (from ./node_modules/svelte-loader/index.js):
Error: ValidationError: :global(...) must contain a single selector (570:2)
568:     transition: opacity 0.2s ease;
569:   }
570:   :global(.rangeSlider, .rangeSlider *) {
       ^
571:     user-select: none;
572:   }

:global(.rangeSlider, .rangeSlider *) {

Thank you.

Question: How could I get this to update based on a changing value?

So, I know you mentioned that you had not intended for this to be a timeline/seekbar, etc...but everything else about it is so nice I was wondering if you had any idea as to how I might go about adding that kind of functionality?

My thought is that the incoming value is a reactive value that is changing (seconds from the current time of a piece of music) so the slider would need the ability to update it's value, and therefore it's position, based on the incoming value, and also be able to set a value be being clicked on, which I think it already does?

Anyway, if you have any thoughts you can share i would be most appreciative :-)

[question] How to change the Height of the Slider?

The slider looks a bit big for me. I tried to make it smaller with

	:global(#slider .rangeSlider) {
            height: 10px !important;
	}

But it seams not to work. How to change the complete height of the element (scale it down)?

bounded percentage range slider

is it possible to have a min range slider to represent 0 to 100 percent, but enable sliding between a bounded range within the min/max range?

I am looking for a way to link multiple percentage sliders to add up to 100

Question: How do I bind to a value from a writable store?

I am trying out your slider in a REPL:

https://svelte.dev/repl/9e6d515b510143e4b1b8a7a01940f0db?version=3.29.6

...where I am trying to use it as a volume slider that is bound to the volume output of the Howler JS Audio library.

At line 40 in the Player.svelte file I have a range input that is bound to the $volume of a store and it works as advertised.

I cannot figure out how to bind that same value to the instance of your slider at line 43 underneath it.

I have the native range commented out and am trying to pass the $volume from the player-lib.js file but can't make it work, so not sure how to go about making it work :-)

Feature Request: Specify Pip Values

Hi there. Great component. The UI is very slick! I'd like to use this in a project, but I want to only show pips for specified values. This is similar to -- but not the same as -- #9.

I'd be happy to open a PR to implement a new prop pipValues that accepts a an array of values, each of which represent a value at which to display a pip.

The native HTML range input supports this feature via a related <datalist/> , which accepts a list of <option/> elements. Each <option/> element has a value attribute that corresponds to a hash mark (or pip).

My use case is generating a range slider with hash marks that represent deciles of data, similar to this native implemenation:
image

It's a way to show the distribution of a dataset.

I'd be happy to open a PR attempting this feature if it's something you'd accept.

[bug] `--range-pip-in-range-text` color not applied on the pip matching the current value

Describe the bug

When the current value of the slider matches exactly one of the pip, the --range-pip-in-range-text color is not applied to that pip.

To Reproduce

Steps to reproduce the behavior:

  1. Open this REPL
  2. See that while the current value is 10, the pip for 10 is not in orange while its value is in the range.

Expected behavior

All pips in the range should be in orange, including the one matching exactly the current value.

Screenshots

Screenshot_20220215_114952

[bug] <RangePips> was created with unknown prop 'orientationEnd'

Thanks for this rather awesome widget!

Describe the bug
I noticed a console message complaining about the unknown prop. Looking at the code it looks like RangeSlider.svelte passes orientationEnd to RangePips.svelte but that property is not defined.

To Reproduce

Steps to reproduce the behavior:

  1. Visit the REPL above (unmodified)
  2. Make the console larger to see the warning
  3. See warning

Expected behavior

No console warning.

Additional context

This does not appear to cause any errors, but the console warning is slightly annoying. I'm unsure if you intended to use orientationEnd but wanted to ensure you're aware of the bug.

Since the bug manifests in the standard REPL, I've not included any screenshots or other environment info, but to be explicit I also see the error in the Chrome inspector console on a Mac with this line to instantiate a RangeSlider:

<RangeSlider bind:values={$daysToReview} float pips {suffix} min={1} max={7} />
$: suffix = $daysToReview[0] > 1 ? " days" : " day";

Make outer slider div bindable

For forms validation, it's important that required but empty inputs can be scrolled into view when the user tries form submission.

Would be great if svelte-range-slider-pips exposed the slider variable for this purpose so people can call

slider.scrollIntoView()

Bug: Setting min and max to zero when component first loads prevents slider ball from moving

So for the past couple hours I have been trying to narrow this bug down to make it reproducible. The exact bug is when the slider starts off at min=0 and max=0, then dynamically changing max prop with a variable to a high number (I.E. 100) the slider ball will stay at the beginning position (not moving to the right) but the value (float prop) above the ball will change when I try to move the slider ball. I looked at the css and it shows left: NaN%. Surprising, If I make max -1 first and then change the max variable like the previous example, the slider ball will move like normal.

Environment: Svelte 3.0

How to reproduce:
Create a max variable and set it to 0
Set slider component props min=0 and max={ max_var }
Then change max_var to 100
Try to slide the slider ball and it will stay in the beginning (initial) position, but the values variable value will update

Spring Animation on Mount

It would be great to have an option to disable the opening animation, and start straight from the handles at their set positions.

[feature] Custom position and naming of pips

I want to change the position of the pips similar to this example but also set custom names for them from JSON.
https://svelte.dev/repl/d777b85ba4c9493a8169676adbab1fa6?version=3.44.1

I also don't want the "snapping" of the pips is there a way to disable it? I only need the pips as a guide.

https://svelte.dev/repl/779c2b76db9a4d179f050b7c599fc874?version=3.49.0

I'll use the Range Slider component inside an each loop so I want to change the pips depending on the data.

[bug] appears that Hoverable not working in REPL

~~ extracted from @wrex previous issue #51

Describe the bug
When hovering with the default CSS variables I'm not seeing the float with the actual value, just the glow around the thumb. Once it's focused, the float appears but not when in hover state.

The doc example shows the float appearing on hover as I'd expect, but it's not appearing for some reason in my instance, despite hoverable being in its default state of true. Doubtless I'm doing something wrong, but I haven't figured it out yet.

EDIT: Actually, I just noticed the the REPL at https://svelte.dev/repl/030797781fd64ad88302d1343f5b2c43?version=3.32.1 exhibits the same behavior (just the glow around the thumb on hover without actually showing the value).

[feature] ...

Really nice implementation!

I haven't played with this much yet but just looking at examples it didn't look like this feature was present.

Describe the feature
Add the ability to use an embedded label inside the slider-thumb ( see attached image ) that remains after releasing the thumb.

Explain it's value / reasoning
When you release the thumb the tool-tip disappears and 'position' becomes nonspecific.

While you could use labeled-pips to solve this there are uses where the labels might take up to much room without overlapping based on the length of the slider ( a few of your examples when viewed on mobile suffer from this )

Additional context
The date range slider is one example where this could work nicely, I think this is a very nice alternative or supplement to pips and tooltips.

NOTE: This might require allowing the user to changing the size of thumb's if that's not already possible

CustomPip

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.