return image back to the original position after a 180 degree rotation

I have written code below to flip an image . I am setting -webkit-transform=rotateY(180deg), but again on the click event I want to bring image back to the original position. I tried -180 value but it's not working.

var status=1;
function flipIt(obj) {
    //$(obj).wrap("<div class='centerImage'></div>")

    console.log("value before Function status   "+status);

    if(status==1) {
        $(obj).css("-webkit-transform-style","preserve-3d");
        $(obj).css("-webkit-transition","all 1.0s linear");
        $(obj).css("transform-style","preserve-3d");
        $(obj).css("transition","all 1.0s linear");

        $(obj).css("-webkit-transform","rotateY(180deg)");
        $(obj).css("transform","rotateY(180deg)");
        //$(obj).css("box-shadow","-5px 5px 5px #aaa");

        status=0;
        console.log("after if value set status   "+status);
    } else {
        $(obj).css("-webkit-transform-style","preserve-3d");
        $(obj).css("-webkit-transition","all 1.0s linear");
        $(obj).css("transform-style","preserve-3d");
        $(obj).css("transition","all 1.0s linear");

        $(obj).css("-webkit-transform","rotateY(-180deg)");
        $(obj).css("transform","rotateY(-180deg)");
        status=1;

        console.log("ater else value set status   "+status);
    }
}

Please Help.

Answers


Try setting it to 0, not minus 180.

$(obj).css("transform","rotateY(0deg)");

Then it won't rotate as I think it's calculated relative to its original rotation.


Need Your Help

Passing data between Python and C# without writing a file

c# python stdout stdin inter-process-communicat

I would like to pass binary information between Python and C#. I would assume that you can open a standard in/out channel and read and write to that like a file, but there are a lot of moving parts...

Create a masterpage that fits any screen resolution

asp.net html css master-pages

I have created a masterpage and I want the ASP.NET pages attached to it to fit any screen resolution. Its a html tables based design.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.