JqueryJquery plugins   PortFolioSenamion's PortFolio HomeHome page corner A jquery blog

Senamion.com


Senamion:

Categorie:

jQuery jScratchcard – Scratchcard effect on image

30 marzo 2010 by Giovanni

A simple jQuery plugin that implement a Scratchcard (Scratch card).

This is a screenshot:

jScratchcard - Scratchcard

Parameters:

  • opacity – opacity step when hover – default {’opacity’: 0.2}
  • color – start background color – default {color: ‘grey’}
  • stepx – x block dimension – default {stepx: 10}
  • stepy – y block dimension – default {stepy: 10}
  • mousedown – if true the left button of mouse must be down – default {mousedown: true}
  • callCallbackPerc – if valorized is the percent at which call callback – default: false
  • callbackFunction – callback function – default null

See it in action!

In Jquery | 12 Comments »

12 Comments a “jQuery jScratchcard – Scratchcard effect on image”

  1. Giovanni scrive:

    New version compatible with ie6 – ie7!

  2. Avery Bishop scrive:

    New version compatible with ie6 – ie7!
    +1

  3. Bob scrive:

    Hi,

    I have used the scratch banner and its working fine…Thank you so much for that…

    I do have a query…

    I need to have a text banner (instead of a plain image) which on scratch will display the image banner…

    Kindly assist me in this regard….

  4. Giovanni scrive:

    You can simply apply jScratchcard to banner, instead of image.

  5. Mostafa Berg scrive:

    Giovani, you’re a JQuery guru :)

    I’m running a facebook application and used flash for the scratch cards in the game.

    I’ve hated the thought of using flash, and decided to find a better way, and I’d like to tell you your work was very inspiring!

    I’m going to rewrite my app to entirely support JQuery and a modified version of your cards

    I’ll send you a link as soon as It’s ready before releasing the game :)

    thanks,
    Mostafa Berg

  6. Matt scrive:

    Hey, this is a great plugin.

    I want to use it to display 3 cards as a game. If the pics behind all match, they win something. I’m going to use PHP to generate the pics but I was wondering is there a method I can use to know when a certain amount, say 50% of the card has been scratched off?

  7. Giovanni scrive:

    Just for Matt: new version 1.0, two new options: callCallbackPerc and callbackFunction
    See demo 2!

  8. Matt scrive:

    Wow, Grazie Giovanni! That is awesome.

    Just one other question, to know if it’s possible : is there a way to have an image over the top instead of colour block

    Exmaple: http://i52.tinypic.com/52xmqf.jpg

    I’m not sure if it’s possible, I wondered, if the block over the top acted like one element then we could set that background-image but I guess it has to be lots of individual elements.

    Kind regards

  9. Matt scrive:

    Hi Giovanni

    Since my cover pieces are quite large, I simply sliced up the image and used the pieces as background-images for them:

    count = 0
    over += “<div …… background-image: url(cover/"+count+".jpg); …..
    count++;

    Seems to work :-)

  10. Tristan scrive:

    Hi Giovanni

    Nice work !
    A few months ago, I’ve extracted a similar script for touch devices. Here’s a working demo on ipad & iphone :
    http://prizeetools.com/gratt/
    But I wasn’t able to make it work on non-touch devices.
    Do you think you could mix it with your script to get a universal scratch script ?

  11. Rudy scrive:

    This is a brilliant script Giovanni!

    What should I add/change to make it work on touch devices such as ipad & iphone?
    Unfortunately the link of Tristan does not work anymore :(

    Thank you in advance!

    Rudy

  12. Matt scrive:

    I’m looking to use this in another project but would need it to work on iphone and ipad devices.

    Is there a way to make it trigger on touch? so that it works mobile and desktop?

Write a comment