1
I managed to do it with jquery, here’s the code for whoever needs it.
<script type="text/javascript" src="dist/jquery/jquery-1.12.3.min.js"></script>
<canvas id="diamond" width="100" height="100"></canvas>
<script type="text/javascript">
var canvas = document.getElementById("diamond");
var context = canvas.getContext("2d");
var diamond = function (x,y){
context.beginPath();
context.moveTo(25,15);
context.lineTo(40,25);
context.lineTo(25,35);
context.lineTo(10,25);
context.lineWidth = 1;
context.fillStyle = "#F2673D";
context.closePath();
context.fill();
}
diamond();
$(document).ready(function() {
$("#diamond").hover(function() {
$(this).stop().animate({ marginTop: "-48px" }, 200);
},function(){
$(this).stop().animate({ marginTop: "-50px" }, 300);
});
});
</script>