scratchie icon indicating copy to clipboard operation
scratchie copied to clipboard

a stupid question...

Open GUOJI opened this issue 10 years ago • 1 comments

could you tell me why all the buttons in the example are not functional? and how to fix it?

GUOJI avatar Mar 07 '16 08:03 GUOJI

The plugin adds a <canvas> on top of the container (and also over your buttons)
Because of this canvas, you can't click anything under it.
The quick fix is to:

  1. Listen to the percentage of the card that was scratched off
  2. Once the user has scratched enough (let's say 60), remove the <canvas> element
  3. As a bonus you can also remove the .js-scratchie class from the container

There might be a better way to do this, but I haven't found it yet.

Example code:

scratchie.onScratchMove = function(percent){
    if (percent > 60) {
        this.canvas.remove();
        this.element.classList = [];
    }
};

bacanu avatar Oct 03 '16 08:10 bacanu