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

vue-sliding-button

v1.0.6

Published

一个 Vue 的滑动按钮组件,拥有优雅的惯性与回弹动画。

Downloads

5

Readme

vue-better-slider

一个 Vue 的滑动按钮组件,拥有优雅的惯性与回弹动画,有关动画方面的处理借鉴 better-scroll 的实现。

在线例子

二维码

起步

安装

npm i --save vue-sliding-button

引入

import Vue from 'vue'
import SlidingButton from 'vue-sliding-button'

Vue.use(SlidingButton)

使用

<template>
    <div>
      <better-slider>
        <div slot="front" class="front">
          前面的内容
        </div>
        <div slot="back" class="back">
          后面的内容
        </div>
      </better-slider>
    </div>
</template>
<script>

</script>

原理

布局

布局

绿色部分为 wrapper,它拥有两个子元素为 back 和 front,它的高度会被 front 撑起。黄色部分为 back,它使用绝对定位,它的高度与 wrapper 相同,值得注意的是为了提高性能,back 在用户触摸该控件是才被插入。front 与 back 同级。

关闭

组件提供关闭动画,调用组件的 close 方法使用,可以通过监听 clickBackEvent 等事件,通过传入的组件引用已调用该方法。需要注意的是,该方法并不会删除该组件,可以通过监听 closeTransitionEndEvent 事件,在其中进行自己的处理。

选项

SlidingButton 支持很多属性。

right

  • 类型:Number
  • 默认值:80
  • 作用:从左向右滑动时,右边展示宽度

left

  • 类型:Number
  • 默认值:80
  • 作用:从右向左滑动时,左边展示宽度

rightBackgroundColor

  • 类型:Number
  • 默认值:80
  • 作用:从左向右滑动时,组件底色,主要用于关闭动画

leftBackgroundColor

  • 类型:Number
  • 默认值:0
  • 作用:从右向左滑动时,组件底色,主要用于关闭动画

momentum

  • 类型:Boolean
  • 默认值:true
  • 作用:表示是否开启惯性动画

momentumTime

  • 类型:Number
  • 默认值:100
  • 作用:表示惯性动画持续时间

deceleration

  • 类型:Number
  • 默认值:0.01
  • 作用:表示惯性动画的减速度

closeTime

  • 类型:Number
  • 默认值:300
  • 作用:表示关闭动画的持续时间

trigger

  • 类型:Boolean
  • 默认值:true
  • 作用:该属性为 true 或 false 并无区别,只要该值发生改变,且用户没有触摸该组件时,就会将组件的 front 置于原始位置。当在列表中使用多个该组件时,可以使用该属性。

事件

注意:event 是事件原生参数,component 是指向该组件的引用。

clickBackEvent

  • 参数:{ Object }.{ event, component }
  • 触发时机:用户点击 back 时

clickFrontEvent

  • 参数:{ Object }.{ event, component }
  • 触发时机:用户点击 front 时

touchStartEvent

  • 参数:{ Object }.{ event, component }
  • 触发时机:用户开始触摸该组件时

closeTransitionEndEvent

  • 参数:{ Object }.{ event, component }
  • 触发时机:关闭动画结束时调用