I'm looking for a technique, example or lib for providing a buffer area around an element to pick up click and hover events.
Specifically this is for a thin separator that I want to have a larger click target.
Any thoughts would be great. The only requirement is that it cannot affect the style of the rest of the page or other nearby click regions (lowest priority event handler).
Update This is where I'm at:
HTML:
<div class="box">
Hi there
<div class="buffer"></div>
</div>
<span class="test">Hi there, I should still be clickable</span>
CSS:
.box {
position: relative;
background: #ccc;
height: 100px;
line-height: 100px;
width: 100px;
text-align: center;
}
.box > .buffer {
position: absolute;
top: -10px;
left: -10px;
background: transparent;
border: 1px solid;
height: 120px;
width: 120px;
}
JS:
var box = document.querySelector('.box');
box.onclick = function(e) {
alert('clicked on buffer')
}
var span = document.querySelector('.test');
span.onclick = function(e) {
alert('clicked on span')
}
JSfiddle: http://jsfiddle.net/ScSEe/
Only remaining issue is that the buffer squelches nearby click regions.
Thanks!