1.0.5 • Published 4 years ago

react-scratch-me v1.0.5

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

A Scratch Card component for React

Demo

https://crowdland.github.io/react-scratch-me/

Installation

// using npm
npm install react-scratch-me --save
// using yarn
yarn add react-scratch-me

Sample usage

import React from "react";
import ScratchMe from "react-scratch-me";
import foregroundImageSrc from "./foreground.jpg";
import backgroundImageSrc from "./background.jpg";

const MyPage = () => (
	<ScratchMe
		width={400}
		height={300}
		foregroundImageSrc={foregroundImageSrc}
		backgroundImageSrc={backgroundImageSrc}
		strokeWidth={20}
		onProgress={percent => console.log(`${percent}% cleared`)}
		onCompleted={() => console.log(`Scratch Card Completed!`)}
		completedAt={30}
	/>
);

export default MyPage;

Properties

NameTypeDescriptionDefault valueRequired
widthnumberWidth of the componentnoneyes
heightnumberHeight of the componentnoneyes
foregroundImageSrcstringThe image to use as foreground (what the user will scratch)noneyes
backgroundImageSrcstringThe image to use as background (what will be revealed)noneyes
strokeWidthnumberWidth of the stroke as you erase the foreground image20no
onProgressfunctionFunction to be executed as the scratching progresses. It will return the current cleared percentage.noneno
onCompletedfunctionFunction to execute when the scratch card has been completednoneno
completedAtnumberPercentage to consider the scratch card to be completed50no
1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago