Proximity event for jQuery: Demo

As you move closer to the box below the red text will get bigger (up to 5em).

MOVE CLOSER!

See the repo here!

// THE SOURCE CODE
            
var box = $('#demo'),
    data = $('#data');

box.bind('proximity', {max:300}, function(e, proximity, distance){
    
    // font-size moves between 10px and 40px
    box.css('font-size', (proximity * 30 + 10) + 'px');
    
    data.text(
        proximity === 0 ?
            '[OUT OF BOUNDS]'
            : 'Distance from box: ' + distance.toFixed(3) + 'px, Proximity: ' + proximity.toFixed(3)
    );
    
    box.css('background', proximity === 1 ? 'yellow' : '');
    
});