Giter Club home page Giter Club logo

slider's Introduction

npm CircleCI npm bundle size (scoped version) Discord npm

Vue 3 Slider






Sponsors


About Vueform

Vueform

Vueform is comprehensive form development framework for Vue.js. It supercharges and standardizes the entire form building process and takes care of everything from rendering to validation and processing. With our latest tool, the Drag and Drop Form Builder, you can allow your developers & non-tech workforce to build the most complex forms without coding.

Feature highlights:

  • integrate Vueform Drag and Drop Form Builder into any application
  • save forms in database as a JSON
  • use your own form elements with custom configuration options
  • a complete theming and templating system with Tailwind support
  • 25+ form elements with multi-file uploads, date pickers and rich text editor
  • element nesting and repeating
  • 50+ validators with async, dependent and custom rules
  • conditional logic on element & form level
  • breaking forms into steps with form wizard
  • translating form content and global i18n support.
Vueform Builder

Learn more:

Other libraries

  • @vueform/multiselect - Vue 3 multiselect component with single select, multiselect and tagging options.
  • @vueform/toggle - Vue 3 toggle component with labels, custom slots and styling options.

Slider features

  • Vue 2 & 3 support
  • 100% coverage
  • TypeScript support
  • ESM support
  • Fully configurable
  • Single slider
  • Multiple sliders
  • Tooltips
  • Formatting
  • CSS vars support
  • Accessibility support
  • Tailwind & utility class support
  • Based on noUiSlider

Sections

Demo

Check out our demo.

Installation

npm install @vueform/slider

Using with Vue 3

<template>
  <div>
    <Slider v-model="value" />
  </div>
</template>

<script>
  import Slider from '@vueform/slider'

  export default {
    components: {
      Slider,
    },
    data() {
      return {
        value: 20
      }
    }
  }
</script>

<style src="@vueform/slider/themes/default.css"></style>

Using with Vue 2

<template>
  <div>
    <Slider v-model="value" />
  </div>
</template>

<script>
  import Slider from '@vueform/slider/dist/slider.vue2.js'

  export default {
    components: {
      Slider,
    },
    data() {
      return {
        value: 20
      }
    }
  }
</script>

<style src="@vueform/slider/themes/default.css"></style>

Using with < Vue 2.7

Switch to <= 2.0.10 to use the Slider with Vue.js < 2.7.

Support

Join our Discord channel or open an issue.

Configuration

Basic props

Name Type Default Description
id string slider The id attribute of slider container DOM.
lazy boolean true Whether to update v-model only when the slider value is set and not while dragging. If disabled you must not use inline objects as props (eg. format, options, classes) but outsource them to a data property.
disabled boolean false Whether the slider should be disabled.
min number 0 Minimum value of the slider.
max number 100 Maximum value of the slider.
step number 1 The jump between intervals. If -1 it enables fractions (eg. 1.23).
tooltips boolean true Whether tooltips should show above handlers.
showTooltip string 'always' When tooltips should be shown. Possible values: always|focus|drag.
merge number -1 The step distance between two handles when their tooltips should be merged (when step is -1 then 1 is assumed). Eg:

{ merge: 5, step: 10 }
-> values: 0, <=50 will merge
-> values: 0, 60 will not merge

{ merge: 5, step: -1 }
-> values: 0, <=5 will merge
-> values: 0, 5.01 will not merge
format object|function Formats the tooltip. It can be either a function that receives a value param and expects a string or number as return or an object with the following properties:
prefix - eg $ -> $100
suffix - eg USD -> 100USD
decimals - eg 2 -> 100.00
thousand - eg , - 1,000
orientation string 'horizontal' The orientation of the slider. Possible values: horizontal|vertical
direction string 'ltr' The direction of the slider. By default value increases left-to-right and top-to-bottom, which is reversed when using rtl. Possible values: ltr|rtl
tooltipPosition string null The position of the slider tooltips. Possible values: null|'top'|'bottom'|'left'|'right' depending on orientation prop. When null it equals to orientation default ('top' for 'horizontal' and 'left' for 'vertical').
aria object An object containing aria attributes to be added for each handle.
ariaLabelledby string null Sets the aria-labelledby attribute of handles.
options object {} Additional options for noUiSlider.
classes object An object of class names that gets merged with the default values. Default:
{
  target: 'slider-target',
  ltr: 'slider-ltr',
  rtl: 'slider-rtl',
  horizontal: 'slider-horizontal',
  vertical: 'slider-vertical',
  textDirectionRtl: 'slider-txt-dir-rtl',
  textDirectionLtr: 'slider-txt-dir-ltr',
  base: 'slider-base',
  connects: 'slider-connects',
  connect: 'slider-connect',
  origin: 'slider-origin',
  handle: 'slider-handle',
  handleLower: 'slider-handle-lower',
  handleUpper: 'slider-handle-upper',
  touchArea: 'slider-touch-area',
  tooltip: 'slider-tooltip',
  tooltipTop: 'slider-tooltip-top',
  tooltipBottom: 'slider-tooltip-bottom',
  tooltipLeft: 'slider-tooltip-left',
  tooltipRight: 'slider-tooltip-right',
  active: 'slider-active',
  draggable: 'slider-draggable',
  tap: 'slider-state-tap',
  drag: 'slider-state-drag'
}
Vueform

Events

Event Attributes Description
@change value Emitted when dragging the slider is finished or it's value changed by clicking, keyboard or programmatical set.
@update value Emitted in the same scenarios as in @change, but also when the slider is being dragged if lazy option is disabled.
@set value Emitted in the same scenarios as in @change, but also when the slider's .set() method is called.
@slide value Emitted while the slider moves.
@drag value Emitted the slider connect moves while dragging.
@start value Emitted when the handle is activated and dragging started.
@end value Emitted when the dragging ended.

Styling

Styling with CSS vars

The following CSS variables can be used to customize slider when using default.css:

--slider-bg: #D1D5DB;
--slider-connect-bg: #10B981;
--slider-connect-bg-disabled: #9CA3AF;
--slider-height: 6px;
--slider-vertical-height: 300px;
--slider-radius: 9999px;

--slider-handle-bg: #fff;
--slider-handle-border: 0;
--slider-handle-width: 16px;
--slider-handle-height: 16px;
--slider-handle-radius: 9999px;
--slider-handle-shadow: 0.5px 0.5px 2px 1px rgba(0,0,0,.32);
--slider-handle-shadow-active: 0.5px 0.5px 2px 1px rgba(0,0,0,.42);
--slider-handle-ring-width: 3px;
--slider-handle-ring-color: #10B98130;

--slider-tooltip-font-size: 0.875rem;
--slider-tooltip-line-height: 1.25rem;
--slider-tooltip-font-weight: 600;
--slider-tooltip-min-width: 20px;
--slider-tooltip-bg: #10B981;
--slider-tooltip-bg-disabled: #9CA3AF;
--slider-tooltip-color: #fff;
--slider-tooltip-radius: 5px;
--slider-tooltip-py: 2px;
--slider-tooltip-px: 6px;
--slider-tooltip-arrow-size: 5px;
--slider-tooltip-distance: 3px;

Override them globally:

:root {
  --slider-connect-bg: #3B82F6;
  --slider-tooltip-bg: #3B82F6;
  --slider-handle-ring-color: #3B82F630;
}

Or on instance level:

<Slider
  v-model="value"
  class="slider-red"
/>

<Slider
  v-model="value"
  class="slider-blue"
/>
.slider-red {
  --slider-connect-bg: #EF4444;
  --slider-tooltip-bg: #EF4444;
  --slider-handle-ring-color: #EF444430;
}

.slider-blue {
  --slider-connect-bg: #3B82F6;
  --slider-tooltip-bg: #3B82F6;
  --slider-handle-ring-color: #3B82F630;
}

Styling with Tailwind CSS

To use the slider with Tailwind CSS you must add it as a plugin to tailwind.config.js:

// tailwind.config.js

module.exports = {
  // ...
  plugins: [
    require('@vueform/slider/tailwind'),
  ]
}

This plugin adds certain utilities and variants which are neccessary for the slider but Tailwind does not provide by default.

After that you need to import themes/tailwind.scss to you main component:

<template>
  <div id="app">
    <Slider ... />
  </div>
</template>

<script>
  // ...
</script>

<style lang="scss">
  @import 'path/to/node_modules/@vueform/slider/themes/tailwind.scss'
</style>

Using :classes prop

Alternatively you can define class names directly by passing them to the Slider component via classes property. When using this approach you don't need to import tailwind.scss. Here's a default styling for Tailwind CSS (the same included in tailwind.scss):

<Slider v-model="value" :classes="{
  target: 'relative box-border select-none touch-none tap-highlight-transparent touch-callout-none disabled:cursor-not-allowed',
  focused: 'slider-focused',
  tooltipFocus: 'slider-tooltip-focus',
  tooltipDrag: 'slider-tooltip-drag',
  ltr: 'slider-ltr',
  rtl: 'slider-rtl',
  horizontal: 'slider-horizontal h-1.5',
  vertical: 'slider-vertical w-1.5 h-80',
  textDirectionRtl: 'slider-txt-rtl',
  textDirectionLtr: 'slider-txt-ltr',
  base: 'w-full h-full relative z-1 bg-gray-300 rounded',
  connects: 'w-full h-full relative overflow-hidden z-0 rounded',
  connect: 'absolute z-1 top-0 right-0 transform-origin-0 transform-style-flat h-full w-full bg-green-500 cursor-pointer tap:duration-300 tap:transition-transform disabled:bg-gray-400 disabled:cursor-not-allowed',
  origin: 'slider-origin absolute z-1 top-0 right-0 transform-origin-0 transform-style-flat h-full w-full h:h-0 v:-top-full txt-rtl-h:left-0 txt-rtl-h:right-auto v:w-0 tap:duration-300 tap:transition-transform',
  handle: 'absolute rounded-full bg-white border-0 shadow-slider cursor-grab focus:outline-none h:w-4 h:h-4 h:-top-1.5 h:-right-2 txt-rtl-h:-left-2 txt-rtl-h:right-auto v:w-4 v:h-4 v:-top-2 v:-right-1.25 disabled:cursor-not-allowed focus:ring focus:ring-green-500 focus:ring-opacity-30',
  handleLower: 'slider-hande-lower',
  handleUpper: 'slider-hande-upper',
  touchArea: 'h-full w-full',
  tooltip: 'absolute block text-sm font-semibold whitespace-nowrap py-1 px-1.5 min-w-5 text-center text-white rounded border border-green-500 bg-green-500 transform h:-translate-x-1/2 h:left-1/2 v:-translate-y-1/2 v:top-1/2 disabled:bg-gray-400 disabled:border-gray-400 merge-h:translate-x-1/2 merge-h:left-auto merge-v:-translate-x-4 merge-v:top-auto tt-focus:hidden tt-focused:block tt-drag:hidden tt-dragging:block',
  tooltipTop: 'bottom-6 h:arrow-bottom merge-h:bottom-3.5',
  tooltipBottom: 'top-6 h:arrow-top merge-h:top-5',
  tooltipLeft: 'right-6 v:arrow-right merge-v:right-1',
  tooltipRight: 'left-6 v:arrow-left merge-v:left-7',
  tooltipHidden: 'slider-tooltip-hidden',
  active: 'slider-active shadow-slider-active cursor-grabbing',
  draggable: 'cursor-ew-resize v:cursor-ns-resize',
  tap: 'slider-state-tap',
  drag: 'slider-state-drag',
}" />

There are certain variants that help detecting different states/config of the slider:

  • h - applied when the slider is horizontal
  • v - applied when the slider is vertical
  • merge-h - applied when the slider is horizontal and tooltips are merged
  • merge-v - applied when the slider is horizontal and tooltips are merged
  • disabled - applied when the slider is disabled
  • txt-rtl-h - applied when the slider is horizontal and text direction is set to rtl
  • tap - applied when the slider bar is being taped to jump to certain position
  • tt-focus - applied when the slider should only display tooltips on focus (showToolip: 'focus') and the slider is not focused
  • tt-focused - applied when the slider should only display tooltips on focus and the slider is focused
  • tt-drag - applied when the slider should only display tooltips on drag (showToolip: 'drag') and the slider is not being dragged
  • tt-dragging - applied when the slider should only display tooltips on drag and the slider is being dragged

The target class receives ltr, rtl, horizontal, vertical, textDirectionRtl, textDirectionLtr, focused, tooltipFocus, tooltipDrag, tap, and drag classes when the related state is applied.

Certain classes do not define any styles (like .slider-horizontal, .slider-vertical) but only required to detect certain states. If you are changing the class list for any class name make sure to always keep the ones that start with slider- to be able to use the utilities mentioned above (h, v, etc).

In case you need to override the same type of utility you might use @neojp/tailwind-important-variant and use eg. bg-green-500!.

Examples

Single slider

<template>
  <Slider
    v-model="value"
  />
</template>

<script>
  import Slider from '@vueform/slider'

  export default {
    components: { Slider },
    data: () => ({
      value: 20
    })
  }
</script>

JSFiddle - Example #1

Multiple slider

<template>
  <Slider
    v-model="value"
  />
</template>

<script>
  import Slider from '@vueform/slider'

  export default {
    components: { Slider },
    data: () => ({
      value: [20, 40]
    })
  }
</script>

JSFiddle - Example #2

Tooltip formatting

<template>
  <Slider
    v-model="value"
    :format="format"
  />
</template>

<script>
  import Slider from '@vueform/slider'

  export default {
    components: { Slider },
    data: () => ({
      value: 20,
      format: function (value) {
        return `${Math.round(value)}`
      }
    })
  }
</script>

JSFiddle - Example #3

Tooltip merging

<template>
  <Slider
    v-model="value"
    :merge="merge"
    :format="format"
  />
</template>

<script>
  import Slider from '@vueform/slider'

  export default {
    components: { Slider },
    data: () => ({
      value: [20, 30, 40],
      merge: 10,
      format: {
        prefix: '$',
        decimals: 2
      }
    })
  }
</script>

JSFiddle - Example #4

Vertical slider

<template>
  <Slider
    v-model="value"
  />
</template>

<script>
  import Slider from '@vueform/slider'

  export default {
    components: { Slider },
    data: () => ({
      value: 50,
      orientation: 'vertical',
      direction: 'rtl'
    })
  }
</script>

JSFiddle - Example #5

License

MIT

slider's People

Contributors

adamberecz avatar chme avatar j-sek avatar mchestnut 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

slider's Issues

Build CSS/SCSS error

Trying to build a project on NUXT 2, but got an error.
I've tried importing both CSS and SCSS to my main SCSS file and to the nuxt config.
Nothing works.

Without explicit importing style - the slider looks incorrect (almost invisible)


ERROR in ./node_modules/@vueform/slider/themes/default.css (./node_modules/css-loader/dist/cjs.js??ref--3-oneOf-1-1!./node_modules/postcss-loader/src??ref--3-oneOf-1-2!./node_modules/@vueform/slider/themes/default.css)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
ParserError: Syntax Error at line: 1, column 41
    at /Users/gen4/Gits/BigDay/STD-visual/node_modules/@vueform/slider/themes/default.css:1:1536
    at Parser.error (/Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss-values-parser/lib/parser.js:127:11)
    at Parser.operator (/Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss-values-parser/lib/parser.js:162:20)
    at Parser.parseTokens (/Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss-values-parser/lib/parser.js:245:14)
    at Parser.loop (/Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss-values-parser/lib/parser.js:132:12)
    at Parser.parse (/Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss-values-parser/lib/parser.js:51:17)
    at parse (/Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss-custom-properties/index.cjs.js:47:30)
    at /Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss-custom-properties/index.cjs.js:333:24
    at /Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss/lib/container.js:194:18
    at /Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss/lib/container.js:139:18
    at Rule.each (/Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss/lib/container.js:105:16)
    at Rule.walk (/Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss/lib/container.js:135:17)
    at /Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss/lib/container.js:152:24
    at Root.each (/Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss/lib/container.js:105:16)
    at Root.walk (/Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss/lib/container.js:135:17)
    at Root.walkDecls (/Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss/lib/container.js:192:19)
    at transformProperties (/Users/gen4/Gits/BigDay/STD-visual/node_modules/postcss-custom-properties/index.cjs.js:330:8)
 @ ./node_modules/@vueform/slider/themes/default.css 4:14-145
 @ ./.nuxt/App.js
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/@nuxt/components/lib/installComponents.js ./.nuxt/client.js

Slider handle does not update position when a new position value is calculated after change event triggered by click or moving with arrows.

Hey, I am trying to send the slider handle back to a default position after the change event is triggered. After the change event is triggered the default position is computed and then set as the new position of the slider handle. This works fine when dragging the slider handle. However, when clicking on a random position on the slider bar or moving the slider handle with the arrows it doesn't seem to work anymore. I'm using v-model directive to pass the position of the slider. I verified the correct position to be sent whenever the event is triggered which is why I'm tempted to think it might be an internal issue. Has anybody come across this so far and is willing to share their input?

Float values rounded to 2 decimals

I have range from 0 -> 0.0065433661231. The UI looks fine but when I fetch the value it shows either 0.00 or 0.01 (if slider is >= 0.005)

Is there a way to increase number of decimals?

I tried
format: { decimals: 6 }

but it only changes decimals in the UI, while the actual value is rounded

Issues when using for audio player position

Hi. I've created a small demo, where I've tried to use this component as progress bar for an audio player:
https://github.com/xorik/slide-player

So I found 2 issues:

  1. When value is changed externally, the component anyways sends update:modelValue events. You can see it in dev tools

Screen Shot 2021-06-09 at 00 35 34

So it makes player stuck on the same place.
  1. I've tried to workaround it, by ignoring this event (with computed), it helped a bit, and it works perfectly in firefox, but in chrome the slider is shaking which is visually not nice.

Any suggestions how to fix it?

Add "slider-focused" class when the component is focused

When a sleek look is wanted, one might want only to show the tooltip when working with the slider.
This is btw default behavior in vue-slider-component.

This can be achieved with styling like this: (when wrapped in a div with class "slider")

.slider .slider-tooltip {
  display: none;
}
.slider:hover .slider-tooltip,
.slider .slider-active .slider-tooltip {
  display: block;
}

However. It would also be desirable to have the tooltip show when the component is focused, so the ones that prefers working with keyboard instead of mouse can see what they are changing the value to.
How can this be achieved?

It would be great if your component added a "slider-focused" class when in focus!

Or alternatively, you could perhaps add an option that triggers the behavior I'm trying to achieve?

How use

hello

  1. how i can calculate label beetween marks value ?
    image

  2. How i can use range color only beetween marks ?
    image
    or if 3 marks or more
    image

  3. how i can dont merge labels for range ?
    image

Final Result what i need :
image

PostCSS loader exceptions coming from calc rules

I encountered a series of build errors when I included <style src="@vueform/slider/themes/default.css"></style> in a Nuxtjs project using PostCSS loader.

The exception was thrown by PostCSS loader, and coming from CSS rules like this one:
right:calc(var(--slider-tooltip-arrow-size, 5px)*-2);

I believe the issue is the - character next to another character without any whitespace to distinguish a negative number from subtraction:
https://developer.mozilla.org/en-US/docs/Web/CSS/calc()#notes

I was able to fix the issue by changing the above line and those similar to it like so:
right:calc(var(--slider-tooltip-arrow-size, 5px) * -2) to distinguish -2 from - 2.

I imagine this problem is introduced during minification?

Support marks

Do you have something like this - label "Min gård" ?
image

Non semantic HTML id tag

The div wrapper for the slider has a slider id. An HTML document cannot have more than one element with the same id, so this become unsemantic when including multiple sliders to a page.

Change slider and tooltip color based on value

Hey, thank you for creating this component!

Is there a way to set different slider and tooltip color as the value changes? 1-10 is red, 11-20 is yellow, 20-30 is green and so on.

I have had a look at the documents and various other slider components but as a new Vue developer, this is seemingly hard. If possible could I get a guide on how to do this? I believe you will help me. Cheers!

TypeScript declaration file missing

Hi, I'm updating my Vue3 application to use TS. I get this error:

TS7016: Could not find a declaration file for module '@vueform/slider'. '[...]/node_modules/@vueform/slider/dist/slider.js' implicitly has an 'any' type. Try npm i --save-dev @types/vueform__slider if it exists or add a new declaration (.d.ts) file containing "declare module '@vueform/slider';"

npm i --save-dev @types/vueform__slider didn't find anything.

What can I do about this ? Thanks !

Error when drag off the end of the slider

If you drag the handle off the end of the slider then mouse up you get error:

Uncaught TypeError: Cannot read properties of null (reading 'classList')
    at slider.js:1:37515

Changing class prop breaks display

I am trying to change the class in a vue way, so I can change the color based on certain input.

Example:
https://jsfiddle.net/afr80kpm/1/

I see this was requested in another issue #17 , although I feel that is a very hacky way around it.

It would be better if I could set a computed property to the props and have it update automatically without having to worry about dom and such.

Styling option

Hi,

Thank you for making this library.
Is there any option for stylings, like background or line thickness?
if my value < 50 then background color turns to red, if my value > 50 then background color turns to green.

[Feature request] Lazy update

IMHO an option to lazy update the slider value would be very valuable when changes trigger computational expensive actions. By lazy I mean that v-model values change when user release the mouse click once in the desired final value.

I've been looking in docs, both this and noUiSlider, and couldn't find any reference to this option. Sorry if I missed.

Drag stops working when I add prefix

When I add a prefix I can't drag the track-thumb anymore. I can only click on the track to change the value.

Snippet:

<Slider v-model="name" :min="min_value" :max="max_value" :format="{'prefix' : '$', 'decimals' : 0, 'thousand' : ',' }"/>

if I remove the :format binding then everything works fine.

Tailwind error: slider-txt-rtl class does not exist

Error message

The `slider-txt-rtl` class does not exist. If `slider-txt-rtl` is a custom class, make sure it is defined within a `@layer` directive.

Dependencies:

"@vueform/slider": "^2.0.9",
"vue": "^3.2.25",

Dev dependencies

"autoprefixer": "^10.4.2",
"postcss": "^8.4.6",
"sass": "^1.51.0",
"tailwindcss": "^3.0.18",
"typescript": "^4.5.4",
"vite": "^2.9.0",

Error only exist when using tailwind.scss import. It's not error when using classes directly.

[Feature] Add "exactInput" option

Hey !

I have a slider going from 100 000 up to 250 000 with a step of 100. Associated to the slider is an input in which the user can adjust the price. The issue i'm facing is that if the user types 123 456 for example, the value will automatically be rounded to the nearest step which is 123 500.

There is an option in NoUiSlider which allows the value to be set exactly but is not currently usable with the SLider component. Would it be possible to have it as a boolean option ?

NoUiSlider related doc : https://refreshless.com/nouislider/slider-read-write/#section-setting)

Thanks in advance !

`update` and `change` event should not be emitted if change is exogenous

When value is updated through v-model (exogenous change) as opposed to user dragging the handle (endogenous change), there is no good reason to emit the update and change events since I can just watch on the value passed into v-model. This makes it hard to differentiate between exogenous and endogenous change

Vue3 - TS build issues

Duplicate identifier 'options'.

options?: object;

Type 'typeof import("~/node_modules/vue/dist/vue")' is not a constructor function type.

declare class Slider extends Vue {

Workaround described in: Issue #18

Wrong file path in index.d.ts + TS build issues

export * from './Toggle';
references to a wrong file ... it should be ./Slider.

Also, Vue 3 has a problem during build with all vueform components because the types extend from Vue. The current workaround ... shims file in project's src folder:

declare module '@vueform/slider/dist/slider.js' {
   import { DefineComponent } from 'vue'
   const component: DefineComponent
   export default component
}

and import component as

import Slider from '@vueform/slider/dist/slider.js`

The same applies to toggle and multiselect.

Property or method "sliderProps" is not defined

Hello, I am trying to use the Vue2 version of this slider but I keep getting this error when I try to render it:

[Vue warn]: Property or method "sliderProps" is not defined on the instance but referenced during render. 
Make sure that this property is reactive, either in the data option or for class-based components, by initializing the property. 
See https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

Does anyone know how can I solve it?

Slider prevents scrolling on mobile.

Hello
The slider appears to be preventing scrolling when touched on a mobile device. I understand that clicking to change value is part of the slider's normal behavior, but it doesn't seem to be a good user experience when the value is changed by mistake while scrolling.
Is there some known way to prevent that from happening?

screen-capture.mp4

Uncaught TypeError: Cannot read properties of null (reading 'classList')

Hi!

I couldn't exactly investigate when this problem is tiggered
in the error this is marked:
t.onblur=function(){V.value.focused.split(" ").forEach((function(t){A.value.classList.remove(t)}))},t.onfocus=function(){V.value.focused.split(" ").forEach((function(t){A.value.classList.add(t)}))}})),j.value=!0},q=function(){M.value.off(),M.value.destroy(),M.value=null},R=function(t,e){j.value=!1,q(),H()};return (0,vue__WEBPACK_IMPORTED_MODULE_0__.onMounted)(H

Im using this for a time slider, i convert the time to seconds.

Any Idea please?

Using options prop breaks dragging

Hi,

If I use the :options prop on the slider (seems to occur no matter what option or even if it's empty) the dragging is broken. I can drag one step, but then the functionallity stops and I can't drag anymore.

Happens to me even if I just add :options="{}" in your examples etc.

Why does this happen and can it be fixed? Thanks for a great component otherwise!

Doesn't work in nuxt: Cannot use import statement outside a module

Hi,

I'm trying to use your slider within a nuxt.js project, but I always get this error:

'Cannot use import statement outside a module'

Composition API is installed and working, can you try the latest stable version of nuxt and see if your instructions still work?

Thank you for your help,
Alessio

Vue 3 styling

Hey! Hi, I'm trying to use this beautiful slider but I'm no able to aply styling. I used the posted demo so I could see my styles working but nothing on my project.

Code:

<template>
  <div>
    <Slider v-model="value" :tooltips="false"/>
  </div>
</template>

<script>
import Slider from '@vueform/slider'

export default {
  components: {
    Slider,
  },
  data() {
    return {
      value: 20
    }
  }
}
</script>

<style  src="@vueform/slider/themes/default.css">
:root{
  --slider-connect-bg: #a594fe;
  --slider-bg: #252525;
  --slider-height: 20px;
  --slider-handle-width: 20px;
  --slider-handle-height: 20px;
  --slider-handle-bg: radial-gradient(circle, rgba(0,0,0,1) 40%, rgba(165,148,254,1) 60%);
  --slider-tooltip-bg: #a594fe;

  --slider-handle-ring-width: 3px;
  --slider-handle-ring-color: #a594fe30;
}
</style>

Thanks and sorry for my English.

Integer overflow

  <Slider
    v-model="val"
    :min="10"
    :max="100"
    :step="1"
  />

v2.0.5

All are integers divisibile by step. On few breakpoints (in my case 43, 47, etc), value overflows into float, f.e. 47.00000001

Passing :disabled property has no effect

I'm currently trying to disable the slider under different circumstances. But adding the prop :disabled to the slider component has no effect on the slider. It is not disabled and can be adapted as before.

My code:

// isPurchasePriceSliderDisabled is a computed property of my component (returns true or false)

<Slider
  v-if="maxValues.purchasePrice"
  v-model="state.sliders.purchasePriceSlider"
  :tooltips="false"
  :step="10000"
  :min="0"
  :max="maxValues.purchasePrice"
  :disabled="isPurchasePriceSliderDisabled"
  @change="sliderFilterChange($event, 'purchasePriceSlider');">
</Slider>

If i'm going to add the disabled property manually in my dev tools, everything works as expected.

Used version: 1.0.3

Kind regards
Magnus

Long float being passed to the format function

My usecase is having a min of 1 and a max of 12 to select an inclusive month range which grabs the english name of the month from an array by key, but for some values it returns really long floats, like for this example: €5.000000000000001

https://jsfiddle.net/gjhdu6pL/

(of course i can and i will round it down on my end to fix my usecase, but i figured i let ya'll know about this one)

Transition duration not working in Chrome

Hello there, thanks for the awesome slider component! :)

I am trying to work with different transition durations when changing the slider value. It works as one would expect in Firefox, but there seems to be a problem in Chrome that I can't wrap my head around...
In short: only the default 0.3s transition duration works. It partially reacts to custom durations, and both in case of .slider-connect and .slider-origin the transition starts with the speed I define, but then 0.3 seconds later it just jumps to the destination value. So it starts out correctly, then "breaks" the transition, and jumps.
The problem is not apparent with the default 0.3s transition-duration, but I even tried to overwrite that 0.3s (for example to 3s) in the module itself (both in default.css and default.scss), and then the issue becomes apparent the same way with any default slider...
Am I missing something here? Or is this some kind of Chrome bug? Any suggestions are welcome. :)

Slider handle position in not in correct

Hi, I am trying to build a slider component on https://message.dk/shop . We are setting the min and max value for the slider and the values seem to be updating correctly, at least when it comes to the numbers under the slider.
The issue is in the thumb in the slider. The position of it is completely off.
Looking into your demo I saw that transform: translate you are using is going to -1000% for the 0 position and mine goes up to 100%. As soon as I add one more 0 in dev tools, position is correct.
Also this only happens in production, development version uses the correct -1000% value.
Do you have any idea of why is there a difference in numbers?

Here are two screen shots of what happens before and after adding additional 0 to the calculation:

before

after

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.