I'm not quite sure that I understand what you are looking for.
I think maybe this can be done without any JavaScript at all? If you want to flip the X axis with some animation?
Hover over image
JSFiddle: Flip Image: hover
For this demonstration, I had to put the HTML image in the <div> wrapper, because otherwise the changes :hover and scale() conflict with each other in a funky way. You will understand if you remove the <div> wrapper.
HTML
<div class="flippy"> <img src="http://lorempixel.com/200/200/"/> </div>
CSS
.flippy>img { -moz-transform:scale(1,1);-webkit-transform:scale(1,1); transform:scale(1,1); -webkit-transition:all 600ms ease;-webkit-transition:all 600ms ease; transition:all 600ms ease; } .flippy:hover>img { -moz-transform:scale(-1,1);-webkit-transform:scale(-1,1); transform:scale(-1,1); }
If you need to control it using JavaScript, it should be simple enough to replace :hover another class, for example .flipped , and then do it as you wish in JS to activate it on and off.
// Chase.
Inverted image on attribute (click-through demo)
jsFiddle: Rollback image by attribute
In this demo, the image is flipped when there is a flipped attribute.
JavaScript:
// Toggles the 'flipped' attribute on the <img> tag. $('.flippy').click(function(){ if ($(this).attr('flipped')) $(this).removeAttr('flipped'); else $(this).attr('flipped','flipped'); });
CSS
.flippy { transform:scale(1,1); transition:all 600ms ease; } .flippy[flipped] { transform:scale(-1,1); }
HTML: <img class="flippy" src="http://lorempixel.com/200/200/"/> - as you can see, we no longer need the <div> shell for this example, since the conflicts are: hover are no longer a problem.
// Chase.