1.5.3 • Published 4 months ago

op-vue-scratchcard v1.5.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Vue Scratch Card

With majority of the code shamelessly stolen from a codepen by Andre Ruffert and React ScratchCard

Installation

$ npm install vue-scratchcard

Example Usage

<template>
  <div id="app">
    <scratch-card :key="renderCount"
                  :cardWidth="cardWidth"
                  :cardHeight="cardHeight"
                  :finishPercent="finishPercent"
                  imageUrl="https://avatars2.githubusercontent.com/u/1077546?s=460&v=4"
                  :brushUrl="brushUrl"
                  :forceReveal="forceReveal">
      <h2 class="card-content">This is a highly secretive message!!!</h2>
    </scratch-card>
    <button @click="forceReveal = true">Force Reveal!</button>
    <button @click="renderCount++">Force Reset</button>
  </div>
</template>

<script>
import ScratchCard from '../src/ScratchCard.vue';
import BRUSH from './brush.png';

export default {
  name: 'app',
  components: {
    ScratchCard,
  },

  data() {
    return {
      renderCount: 0,
      cardWidth: 300,
      cardHeight: 300,
      finishPercent: 70,
      brushUrl: BRUSH,
      forceReveal: false,
    };
  },
};
</script>

<style scoped>
.card-content {
  color: red;
}
</style>

Parameters:

ParameterTypeDescription
imageUrlStringcover image url
brushUrlStringbrush image url
cardWidthNumbercard width
cardHeightNumbercard height
finishPercentNumberrevelation percentage until removing cover
forceRevealBooleanremove cover when changed from false -> true
@complete (new in 1.2.0)Eventevent emitted on cover revelation
onComplete (deprecated)Functioncallback on cover revelation

As a Vue practice, to force reset a scratchcard, provide a key attribute and change its value. Just as explained in this post.

Change Log:

1.2.0 - 2019-05-04

  • @complete event for cover revelation (by NahroTo)
  • Deprecate onComplete handler

before 1.2.0

  • Untracked 😂
1.5.3

4 months ago

1.5.2

6 months ago

1.5.1

6 months ago

1.5.0

6 months ago

1.3.7-a

8 months ago

1.3.6-a

8 months ago

1.3.5-a

8 months ago

1.3.4-a

8 months ago

1.3.9-a

8 months ago

1.3.8-a

8 months ago

1.4.8-a

8 months ago

1.4.7-a

8 months ago

1.4.9-a

8 months ago

1.4.4-a

8 months ago

1.4.3-a

8 months ago

1.4.6-a

8 months ago

1.4.5-a

8 months ago

1.4.0-a

8 months ago

1.4.2-a

8 months ago

1.4.1-a

8 months ago

1.3.1-a

8 months ago

1.3.0-a

8 months ago

1.2.9-a

8 months ago

1.2.8-a

8 months ago

1.2.7-a

8 months ago

1.2.6-a

8 months ago

1.2.5-a

8 months ago

1.2.4-a

8 months ago

1.2.3-a

8 months ago

1.2.2-a

8 months ago

1.2.1-a

8 months ago

1.2.0-a

8 months ago

1.2.0-b

8 months ago