Is it possible to fix the hovering on http://jsfiddle.net/2AXhR/ so that the correct triangle is activated on hover instead of its sometimes adjacent one? Sometimes the wron
I actually solved the problem on my own. Using JavaScript, I set a hover event for each triangle: On hover, I set its own z-index to 20, the next triangle's z-index to 21, and all the rest of the triangles' z-index to 19.
The code looks like this:
self.e.find(".t div").hover(
function() {
$(this).css({
'z-index': 20,
'border-color': "transparent transparent "+self.params['colorSelected']+" transparent"
});
if($(this).next().length) {
$(this).next().css("z-index", 21);
} else {
self.e.find(".t div").first().css("z-index", 21);
}
},
function() {
self.e.find(".t div").css({
'z-index': 19,
'border-color': "transparent transparent "+self.params['color']+" transparent"
});
});
The reason why it works is because all the triangles are in order starting from the top left going clockwise. Each triangle incorrectly overlaps its next sibling, so by bringing the next sibling forward in the z plane, it allows the triangles to be defined correctly.
Compare these two JSFiddles, and you'll see the difference in hover behavior:
Unsolved: http://jsfiddle.net/2AXhR/
Solved: http://jsfiddle.net/2AXhR/1/