I want to animate a div by first making it's border thicker by 5px on mouseenter, then decreasing the border by 5px on mouseleave, the tricky part is that I don't want the div to look like it's moving (if you just animate the borders, the whole div will look like it shifts, not just the border getting thicker/thinner). I'm very close, but I'm stuck on the last part: mouseleave. What I have so far is:
$("#thumbdiv<%=s.id.to_s%>").bind({
mouseenter: function(){
$(this).animate({
borderRightWidth: "25px",
borderTopWidth: "25px",
borderLeftWidth: "25px",
borderBottomWidth: "25px",
margin: "-5px"
}, 500);
},
mouseleave: function(){
$(this).animate({
borderRightWidth: "20px",
borderTopWidth: "20px",
borderLeftWidth: "20px",
borderBottomWidth: "20px",
margin: "0px"
}, 500);
}
});
I set the border to be 20px somewhere before this, and the margin is not set, so it's 0px. The div animates just fine on mouseenter, I can make the border thicker without the div actually moving out of place, but when the mouseleave is triggered, the div will first relocate itself to the position as if the "margin -5px" was never called, and then decrease it's border slowly and it seems like the "magin: '0px'" isn't actually being called.
I'm not sure if my description makes sense, I can put up a prototype if needed.