npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ophiuchus/slider

v1.0.1

Published

### 介绍

Downloads

1

Readme

Slider 滑块

介绍

滑动输入条,用于在给定的范围内选择一个值。

引入

import Vue from 'vue';
import Slider from '@ophiuchus/slider';

Vue.use(Slider);

代码演示

基础用法

<sf-slider v-model="value" @change="onChange" />
import Toast  from '@ophiuchus/toast';

export default {
  data() {
    return {
      value: 50,
    };
  },
  methods: {
    onChange(value) {
      Toast('当前值:' + value);
    },
  },
};

双滑块

添加 range 属性就可以开启双滑块模式,确保 value 的值是一个数组。

<sf-slider v-model="value" range @change="onChange" />
import Toast  from '@ophiuchus/toast';

export default {
  data() {
    return {
      // 双滑块模式时,值必须是数组
      value: [10, 50],
    };
  },
  methods: {
    onChange(value) {
      Toast('当前值:' + value);
    },
  },
};

指定选择范围

<sf-slider v-model="value" :min="-50" :max="50" />

禁用

<sf-slider v-model="value" disabled />

指定步长

<sf-slider v-model="value" :step="10" />

自定义样式

<sf-slider v-model="value" bar-height="4px" active-color="#ee0a24" />

自定义按钮

<sf-slider v-model="value" active-color="#ee0a24">
  <template #button>
    <div class="custom-button">{ { value } }</div>
  </template>
</sf-slider>

<style>
  .custom-button {
    width: 26px;
    color: #fff;
    font-size: 10px;
    line-height: 18px;
    text-align: center;
    background-color: #ee0a24;
    border-radius: 100px;
  }
</style>

垂直方向

设置 vertical 属性后,滑块会垂直展示,且高度为 100% 父元素高度。

<div :style="{ height: '150px' }">
  <sf-slider v-model="value" vertical @change="onChange" />
  <sf-slider
    v-model="value2"
    range
    vertical
    style="margin-left: 100px;"
    @change="onChange"
  />
</div>
import Toast  from '@ophiuchus/toast';

export default {
  data() {
    return {
      value: 50,
      value2: [10, 50],
    };
  },
  methods: {
    onChange(value) {
      Toast('当前值:' + value);
    },
  },
};

API

Props

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | value | 当前进度百分比 | number | array | 0 | | max | 最大值 | number | string | 100 | | min | 最小值 | number | string | 0 | | step | 步长 | number | string | 1 | | bar-height | 进度条高度,默认单位为px | number | string | 2px | | button-size | 滑块按钮大小,默认单位为px | number | string | 24px | | active-color | 进度条激活态颜色 | string | #1989fa | | inactive-color | 进度条非激活态颜色 | string | #e5e5e5 | | range | 是否开启双滑块模式 | boolean | false | | disabled | 是否禁用滑块 | boolean | false | | vertical | 是否垂直展示 | boolean | false |

Events

| 事件名 | 说明 | 回调参数 | | ---------- | ------------------------ | --------------- | | input | 进度变化时实时触发 | value: 当前进度 | | change | 进度变化且结束拖动后触发 | value: 当前进度 | | drag-start | 开始拖动时触发 | - | | drag-end | 结束拖动时触发 | - |

Slots

| 名称 | 说明 | | ------ | -------------- | | button | 自定义滑动按钮 |

样式变量

组件提供了下列 Less 变量,可用于自定义样式,使用方法请参考主题定制

| 名称 | 默认值 | 描述 | | --------------------------------- | ------------------------------ | ---- | | @slider-active-background-color | @blue | - | | @slider-inactive-background-color | @gray-3 | - | | @slider-disabled-opacity | @disabled-opacity | - | | @slider-bar-height | 2px | - | | @slider-button-width | 24px | - | | @slider-button-height | 24px | - | | @slider-button-border-radius | 50% | - | | @slider-button-background-color | @white | - | | @slider-button-box-shadow | 0 1px 2px rgba(0, 0, 0, 0.5) | - |