Click highlighting

with CSS transitions

This is an experiment that uses CSS transitions to simulate a "you are here" state of clicks to use in presentations and tutorials.

  • Example/Usage
  • Customising
  • Dependencies
  • Download
  • More info
  • License

Example

This page is already the example for the effect. Click anywhere to see a red dot grow from where you clicked. The dot stays until you release the mouse. All you need to do is include clickhighlight.js and call its init() method.

<script src="clickhighlight.js"></script>
<script>clickhighlight.init();</script>

Browsers that do not support CSS transitions will not get any effect but won't break or throw errors either.

Customising

The way to customise the look and feel of the effect is to send parameters when intialising:

clickhighlight.init({
  size:        '300px', // the maximum size of the dot
  duration:    '2s',    // duration of the effect (seconds) 
  colour:      'green', // the dot colour - RGBA = transparency 
  nohighlight: 'notme'  // class of elements not highlighted
});

As you can see there is a class name you can apply to elements you don't want the highlight effect to be applied to. By default, adding a nohighlight class to an element will make sure the effect does not happen (as shown in the links on this page). By default, the highlight effect does not interfere with click events. However on IE and Opera you need to set this class as they don't support CSS pointer events like Webkit and Gecko.

Dependencies

The effect is driven by CSS transitions. If your browser does not support them then there will not be any effect as the script uses feature detection. If you are looking for a jQuery solution with support for older browsers, check ClickEcho.

Download

This project is hosted on GitHub, which means your best choice is to clone it from there or download the zipped versions here.

  • Fork On GitHub
  • ZIP
  • TAR

More information

If you want to know more about what is going on here, check out the Click highlighting with CSS transitions post on hacks.mozilla.org.

License

clickhighlight.js is a script by Christian Heilmann licensed with BSD.

Written by Chris Heilmann (@codepo8) - Sandstone template by Sean Martell.