Smooth Highlighting for Better Eye Leading

What is It?

This is an attempt to make it easier for the user to determine what is happening on a web page when they click a button and some action is performed. Now before you get all excited, this is really a raw proof-of-concept script. Nothing fancy, but it could be added to to make it more flexible and more abstracted for use across multiple places.


Demonstration

Column 1 Column 2




Click on one of the buttons to see what happens

Source


/*
recursive function for highlighting something by running through a set of colors.
really, really simple-minded function, requires that you declare an array of colors (6 to be exact)
named colors, and it only will do from the first color to the last color and back again, finally
ending on the final_color value you pass in. No calculations are currently done to interpolate
'tween colors, it is all dependent on the array.
*/
function change_shading(element_id, cur_val, direction, final_color) {
document.getElementById(element_id).style.backgroundColor = colors[cur_val];
if (direction == 'forward' && cur_val < 6) {
cur_val++;
setTimeout("change_shading('" + element_id + "'," + cur_val + ",'forward','" + final_color + "')",50);
} else if (direction == 'forward' && cur_val == 6) { cur_val--; setTimeout("change_shading('" + element_id + "'," + cur_val + ",'backward','" + final_color + "')",50);
} else if (direction == 'backward' && cur_val > 0) {
cur_val–; setTimeout(”change_shading(’” + element_id + “‘,” + cur_val + “,’backward’,'” + final_color + “‘)”,50);
} else if (direction == ‘backward’ && cur_val == 0) {
document.getElementById(element_id).style.backgroundColor = final_color;
}
}
// currently this is hard-coded to use an array of this name, but it could be changed without too much effort
var colors = new Array();
colors[0] = ‘#FFF’;
colors[1] = ‘#EEE’;
colors[2] = ‘#DDD’;
colors[3] = ‘#CCC’;
colors[4] = ‘#BBB’;
colors[5] = ‘#AAA’;
colors[6] = ‘#999′;

2 Responses to “Smooth Highlighting for Better Eye Leading”

  1. Doctor J Says:

    I don’t get it.

  2. tomjnsn Says:

    When you clicked on the buttons did anything happen to either of the two texts above (’Column 1′, ‘Column 2′)? You should have seen the background quickly fade in and then fade back out.

    The significance of this is mainly for web developers. Traditionally things like this were done with Flash or some other heavy handed method that isn’t built into the browser.