@dellamora/scratch-to-reveal-svelte
v1.0.5
Published
A simple and customizable scratch-to-reveal component for Svelte
Maintainers
Readme
Scratch to Reveal Svelte
Installation
npm i scratch-to-reveal-svelteMinimal Example
<ScratchToReveal
width={250}
height={250}
minScratchPercentage={70}
gradientColors={["#A97CF8", "#F38CB8", "#FDCC92"]}
onComplete={() => console.log('done!')}
>
<p style="font-size: 6rem;">Hiii</p>
</ScratchToReveal>Props
width/height→ Canvas sizeminScratchPercentage→ When to trigger complete eventgradientColors→ Overlay colorsimageUrl→ Optional image to use instead of gradientonComplete→ Completion callbackclassName→ Custom CSS classes
Events
on:complete→ Fired when reveal threshold is hiton:scratchProgress→ Live percentage updates
Methods
.reveal()→ Reveal all content programmatically.reset()→ Reset to initial scratch state
License
MIT. Build fun stuff.
Contributing
PRs welcome!
