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-backgrounds

v1.0.80

Published

Vue 版本的粒子效果。[react-particle-effect-button](https://github.com/transitive-bullshit/react-particle-effect-button) 的 Vue 移植。除 Vue 框架外零依赖。

Downloads

56

Readme

vue-backgrounds (demo)

项目介绍

Vue 版本的粒子效果。react-particle-effect-button 的 Vue 移植。除 Vue 框架外零依赖。

软件架构

核心文件只有一个: particle-effect.vue

安装教程

particle-effect.vue 复制到你的项目目录中,自行修改适配。

下载项目所有文件后,如果想在本地调试代码,请执行以下命令:

yarn install
yarn dev

使用说明

<script>
import ParticleEffect from './particle-effect'

export default {
  data() {
    return {
      effectHidden: false,
    }
  },
  methods: {
    onBegin() {
      console.log('begin event')
    },
    onComplete() {
      console.log('complete event')
    },
  },
}
</script>

<template>
  <ParticleEffect
    :hidden="effectHidden"
    direction="left"
    particle-type="circle"
    particle-style="fill"
    particle-color="#000"
    :duration="1000"
    easing="easeInOutCubic"
    :canvas-padding="150"
    :size="4"
    :speed="2"
    :particles-amount-coefficient="3"
    :oscillation-coefficient="20"
    @begin="onBegin"
    @complete="onComplete"
  >
    BUTTON CONTENT GOES HERE
  </ParticleEffect>
</template>

ParticleEffect组件中,由于使用了slot,子节点除了可以是一个简单的button外,还可以是更复杂的VNode

通过修改hidden属性的值,来启动粒子动画。比如用户点击了按钮,程序把hidden绑定的变量设为true,按钮便会在粒子动画中慢慢消失。

属性参考

  • hidden

类型:Boolean

默认值:false

说明:ParticleEffect组件会监控该属性的变化,从而启动相应的特效动画。

  • direction

类型:String

默认值: 'left'

说明:可选值包括'left', 'right', 'top', 'bottom'

  • particleType

类型:String

默认值:'circle'

说明:可选值包括'circle', 'rectangle', 'triangle'

  • particleStyle

类型:String

默认值:'fill'

说明:可选值包括'fill', 'stroke'

  • particleColor

类型:String

默认值:'#000'

  • duration

类型:Number

默认值:1000

说明:单位是毫秒。

  • easing

类型:StringArray

默认值:'easeInOutCubic'

说明:当绑定的值类型为String时,使用预设缓动函数,以ease开头。具体参考源码以及速查表。目前只支持一部分常见的缓动函数,可以通过传入含有四个数值的数组进行自定义。

  • canvasPadding

类型:Number

默认值:150

说明:单位是像素。在画布上预留额外的空间来显示动画。

  • size

类型:NumberFunction

默认值:() => Math.floor(Math.random() * 3 + 1)

说明:单位是像素。

  • speed

类型:NumberFunction

默认值:() => rand(4)

说明:rand函数的定义参见源码

  • particlesAmountCoefficient

类型:Number

默认值:3

  • oscillationCoefficient

类型:Number

默认值:20

事件参考

  • begin

说明:动画开始时触发。

  • complete

说明:动画结束时触发。