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

scratchers

v0.7.0

Published

经典刮刮卡库, [效果预览](https://codepen.io/liejiayong/pen/eYpOypR)

Downloads

19

Readme

scratchers.js

经典刮刮卡库, 效果预览

特性

  • 兼容 pc ie9+ 及现代浏览器
  • 支持移动端,且图片比例自适应
  • 支持可定制化
  • 用 rollup 压缩打包,支持 es 模式与立即执行模式

Usage

install


npm i scratchers -S

use

import Scratchers from 'scratchers'
// 实例化:el 为挂载点
const install = new Scratchers(el, {
	width: 300, // canvas 宽
	height: 150, // canvas 高
	awardUrl: '', // 奖品图片
	awardColor: '#ffffff', // 奖品默认背景,默认为透明:transparent
	awardMsg: '特等奖', // 奖品文字
	font: 'bold 30px Arial', // 奖品字体样式
	fontColor: '#ffffff', // 奖品字体颜色
	coverUrl: '', // 覆盖层图片
	coverColor: '#cccccc', // 纯色覆盖层
	radius: 28, // 擦除手势半径
	duration: 500, // 展现全部的淡出效果时间(ms)
	percent: 60, // 刮开面积 占 整张刮卡的百分比
	unit: 'px', // 宽高css单位
	containerClass: 'jy-scraping-container', // 装载刮卡的父元素类名
	mode: 'default', // 刮刮卡刮开卡片模式。default:默认模式,一个个像素点刮开;sector:快速模式,以鼠标按下点开始到结束点形成扇形消除像素
	onReady: function() {
		console.log('scratchers ready')
	},
	onProgress: function(rate) {
		console.log('scratchers progress', rate)
	},
	onSuccess: () => {
		console.log('scratchers done')
	} // 全部刮开回调
})

API

  • 设置可刮
install.setLock(false)
  • 设置奖品
install.set({
	coverUrl: 'https://img.zcool.cn/community/01dbd25e8c7128a801216518adf279.jpg@1280w_1l_2o_100sh.jpg',
	awardUrl: 'https://img.zcool.cn/community/01f9485e8af38da801216518361916.jpg@260w_195h_1c_1e_1o_100sh.jpg',
	msg: '特等奖'
})