Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-slider-component

Package Overview
Dependencies
Maintainers
1
Versions
210
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-slider-component

Can use the Slider component in vue1.x and vue2.x

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
59K
decreased by-8.72%
Maintainers
1
Weekly downloads
 
Created
Source

vue-slider-component

Can use the slider in vue1.x and vue2.x

Live Demo

Install

npm install vue-slider-component

Todo

  • Basis
  • Display maximum value & minimum value
  • piecewise style
  • Compatible with PC and mobile terminal
  • Tooltip
  • The custom data
  • Range
  • The vertical component

Example

cd vue-slider-component/example
npm install
npm run dev
npm run build

usage

Use in vue1.x

e.g:

<template>
    <div>
        <vue-slider v-ref:slider :val.sync="val" @callback="getValue"></vue-slider>
    </div>
</template>
<script>
import vueSlider from 'vue-slider-component/src/vue-slider.vue';

new Vue({
  el: '#app',
  components: {
    vueSlider
  },
  data: {
    val: 1
  }
  methods: {
    getValue(val) {
      console.log(val)
    },
    setValue(num) {
      this.val = num
    }
  }
});
</script>

Use in vue2.x
Because```.sync``` was deprecated. Props are now always one-way down. So in order to realize the two-way, Can be set in the @callback

e.g:

<template>
    <div>
        <vue-slider ref="slider" :val="val" @callback="getValue"></vue-slider>
    </div>
</template>
<script>
import vueSlider from 'vue-slider-component'

new Vue({
  el: '#app',
  components: {
    vueSlider
  },
  data: {
    val: 1
  }
  methods: {
    getValue(value) {
      /* Two-way */
      this.val = value
    },
    setValue(num) {
      this.val = num
    }
  }
});
</script>

Use with Browserify (vueify)
Use this little fix:

e.g:

import vueSlider from 'vue-slider-component/src/vue2-slider.vue'

Options

Props

PropsTypeDefaultDescription
class-nameStringnullthe custom class
stylesObjectnullthe custom styles
directionStringhorizontalset the direction of the component, optional value: ['horizontal', 'vertical']
event-typeStringautothe event type, optional value: ['auto', 'touch', 'mouse', 'none']
widthNumber[,String(in horizontal)]150width of the component
heightNumber[,String(in vertical)]4height of the component
dot-sizeNumber15size of the sliders
minNumber0the minimum value
maxNumber100the maximum value
intervalNumber1the gap between the values
showBooleantruedisplay of the component
speedNumber0.5transition time
disabledBooleanfalsewhether to disable components
piecewiseBooleanfalsedisplay of the piecewise
tooltipString,Booleanfalsecontrol the tooltip, optional value: ['hover', 'always', false]
tooltip-dirStringtop(in horizontal)or left(in vertical)set the direction of the tooltip, optional value: ['top', 'bottom', 'left', 'right']
reverseBooleanfalsewhether the component reverse (such as Right to left, Top to bottom)
valNumber,Array0initial value (if the value for the array open range model)
dataArraynullthe custom data

Function

NameTypeDescription
setValueParams: value[Number, Array]set value of the component
setIndexParams: index*[Number]set index of the component
getValueReturn: value[Number, Array]get value of the component
getIndexReturn: index*[Number]get index of the component
refreshnullRefresh the component
  • [ index ] is the index to the array in the custom data model *
  • [ index ] is equal to (( value - min ) / interval ) in normal mode *

Events

NameTypeDescription
callbackParams: value[Number]values change when the callback function
drag-startParams: context[Object]Drag the start event
drag-endParams: context[Object]Drag the end event

License

The MIT License

Keywords

FAQs

Package last updated on 11 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc