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

  • 2.0.8
  • Source
  • npm
  • Socket score

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

vue-slider-component

build build build

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

Live Demo

Install

npm install vue-slider-component

Update

  • Remove class-name & styles (can use vue native props [style, class])
  • Remove val prop, use v-model set value (Don't need to manually two-way binding)
  • Optimize the click range
  • No longer update vue1.x, but still can be normal use
  • Add lazy prop
  • Support array setIndex method parameters
  • Support ie 9+
  • Add props *-style for the custom style
  • Add formatter prop

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 example/

# install dependencies
npm install

# serve with hot reload at localhost:9000
npm run dev

usage

Use in vue1.x

e.g:

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

new Vue({
  el: '#app',
  components: {
    vueSlider
  },
  data: {
    value: 1
  }
});
</script>

Use in vue2.x

e.g:

<template>
  <div>
    <vue-slider ref="slider" v-model="value"></vue-slider>
  </div>
</template>
<script>
import vueSlider from 'vue-slider-component'

new Vue({
  el: '#app',
  components: {
    vueSlider
  },
  data: {
    value: 1
  }
});
</script>

Use with Browserify (vueify)
Use this little fix:

e.g:

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

Options

Props

PropsTypeDefaultDescription
directionStringhorizontalset the direction of the component, optional value: ['horizontal', 'vertical']
event-typeStringautothe event type, optional value: ['auto', 'touch', 'mouse', 'none']
widthNumber[,String(in horizontal)]autowidth of the component
heightNumber[,String(in vertical)]6height of the component
dot-sizeNumber16size 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)
valueNumber,Array0initial value (if the value for the array open range model)
dataArraynullthe custom data.
lazy*BooleanfalseAt the end of the drag and drop, to synchronization value (if each update to high consumption of operation (such as Ajax), it is more useful)
formatter*String,FunctionnullFormatting a tooltip values, Example: formatter='¥{value}' or formatter: (v) => `¥${v}`. demo here
bg-style*ObjectnullThe style of the background.
slider-style*ObjectnullThe style of the slider.
process-style*ObjectnullThe style of the process bar.
piecewise-style*ObjectnullThe style of the piecewise dot.

prop*: [only support vue2]

Function

NameTypeDescription
setValueParams: valueset value of the component
setIndexParams: index*set index of the component
getValueReturn: valueget value of the component
getIndexReturn: index*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 staUnable to initialize the width componentsrt event
drag-endParams: context[Object]Drag the end event

Exceptions

if the component initialization in a v-show="false" container, will appear exception( The slider cannot be used, because the component unable to initialize the size in display: none ).

The solution:

  1. using v-if instead of v-show.
  2. use prop show to control display.
  3. After the set v-show="true", to call the refresh method.

for example:

this.show = true
this.$nextTick(() => {
    this.$refs.slider.refresh()
})

License

MIT

Keywords

FAQs

Package last updated on 09 Dec 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