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

maskcard

v1.0.2

Published

A scratchcard plug-in based on canvas.(基于canvas的刮刮卡插件)

Downloads

18

Readme

maskcard

This is a scratchcard plug-in based on canvas.

(这是一个基于canvas的刮刮卡插件)

Installation and Usage(安装和使用)

npm install maskcard --save
import Maskcard from 'maskcard'

new Maskcard(element, config)

Example(示例)

【example】

API

Maskcard config

Name | type | Description | Default --- | --- | --- | --- fill.type | String | color or image | color fill.content | String | When fill.type is color, fill color value(当fill.type=color时, 填color值)When fill.type is image, fill image url or base64 encoding(当fill.type=image时, 填图片地址或者base64编码) | silver percent | Number(Integer between 0 and 100) | When xx% auto complete(刮到xx%时自动清除) | 100 radius | Number(Integer) | The radius of a scratching path(涂抹笔触半径) | 20 disable | Boolean | Whether disable(是否禁用) | false beforeInit | Function | Called before initialized(初始化之前调用) | null inited | Function | Called after initialized(初始化之后调用) | null touchstart | Function | Called when touchstart, argument: e(初始化之后调用, 参数: e) | null touchmove | Function | Called when touchmove, argument: e(手指移动的时候调用, 参数: e) | null touchend | Function | Called when touchend, argument: e(手指离开的时候调用, 参数: e) | null complete | Function | Called when completed(刮完时调用) | null

Maskcard methods(函数方法)

Name | Description --- | --- clear() | Complete this scratchcard(自动刮完) getProgress() | Compute the current scratching progress(刮到多少百分比) disable() | Disable this scratchcard(禁用刮刮卡) enable() | Enable this scratchcard(启用刮刮卡) changeConfig(config) | Change the config and take effect(修改config) reset() | Reset this scratchcard(重新初始化)

Attention(注意)

Because the 'getImageData' method on 'CanvasRenderingContext2D' does not support cross-domain, so, when fill.type is image, fill.content image url must follow a master file with the domain name. Otherwise program would change the function auto complete into another function that after 10 to complete.

fill.content图片跨域: 因为canvas中的getImageData方法不支持跨域, 所以当参数fill.type=image时, fill.content填的图片地址必须与主文件同域, 否则程序会把自动涂抹功能改为刮了【percent/10】次之后自动抹去.