I am trying to create a function where a #div
will TILT 15 degrees to the left on click, and then go back to the previous position shortly after, but I think this can be easily added to the solution with adding a Timing event. But the Tilt is what I am having the most trouble with. Ideally I would do this with JavaScript alone; but would be open to jQuery and or CSS3.
I have used the below snippet while creating a custom shake.
jQuery.fn.shake = function() {
this.each(function(i) {
$(this).css({ "position" : "relative" });
for (var x = 1; x <= 3; x++) {
$(this).animate({ left: -15 }, 10).animate({ left: 0 }, 50).animate({ left: 15 }, 10).animate({ left: 0 }, 20);
}
});
return this;
}
But it doesn't allow; or I have had no such luck -- creating a 'TILT' effect, only a horizontal or vertical side to side effect. I am assuming I may need to get some CSS3 in there. Any pointers?
DISCLAIMER: I am hoping for a solution of primary JavaScript; as I am supporting IE 9+ / Modern Browsers (chrome, ff, safari). Otherwise there is no real point of implementing at this point. Thanks.