canvas-scratch-card

1.0.4 • Public • Published

canvas-scratch-card

scratch card plugin base on Canvas,Compatible with pc and mobile

how to use?

import scratchCard from 'canvas-scratch-card';
scratchCard.init({
  dom: document.getElementById('id'),
  r: 20, // radius default 20
  rate: 0.5, // when to call callback 0.1 - 1,
  image: 'https://xxxx.jpg', // <img> dom or url
  fillColor: '#b22', // fillColor, when this prop set, image will not render
  callback: () => {
    alert('haha');
  },
});
 
// reset
scratchCard.reset();

example

pc & mobile

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i canvas-scratch-card

      Weekly Downloads

      66

      Version

      1.0.4

      License

      MIT

      Unpacked Size

      7.39 MB

      Total Files

      8

      Last publish

      Collaborators

      • coolapt