Image Rotate Script using Jquery

Image Rotate Script using Jquery:

This script is used to Rotate the image manually , This is a simple plugin to allow you to rotate images  on client side. Main focus is to unify this behavior across different browsers. This rotation script is rotate an image using user input or user values.

In this script i given the value of the image are the 30, 60, 90,180,-180,360 Degrees , The image will rotate based on this given value. I hope this will helpful some where in programming.


image rotation script

Image Rotate Script:

<html>
<head>
<title>jQuery Image Rotate</title>
<script src="http://code.jquery.com/jquery-2.1.1.js"></script>
<script>
function rotateImage(degree) {
$('#demo-image').animate({  transform: degree }, {
    step: function(now,fx) {
        $(this).css({
            '-webkit-transform':'rotate('+now+'deg)', 
            '-moz-transform':'rotate('+now+'deg)',
            'transform':'rotate('+now+'deg)'
        });
    }
    });
}
</script>
<style>
#demo-image{padding:35px 15px;}
.btnRotate {padding: 15px 20px;border:1px solid #000; background-color:#999;color: #000;cursor: pointer;}
</style>
</head>
<body>
<div style="height:600px; width:800px; background-color:#CCC; border:1px solid #000; border-radius:6px; margin-left:auto; margin-right:auto;">
<div style="width:550px; margin-left:auto; margin-right:auto;">
<label>Rotate Image:</label>
<input type="button" class="btnRotate" value="30" onClick="rotateImage(this.value);" />
<input type="button" class="btnRotate" value="60" onClick="rotateImage(this.value);" />
<input type="button" class="btnRotate" value="90"onClick="rotateImage(this.value);" />
<input type="button" class="btnRotate" value="180" onClick="rotateImage(this.value);" />
<input type="button" class="btnRotate" value="-180" onClick="rotateImage(this.value);" />
<input type="button" class="btnRotate" value="360" onClick="rotateImage(this.value);" />
</div>
<div style="width:350px; margin-left:auto; margin-right:auto; margin-top:25px;"><img src="image-rotating-script-using-jquery .jpg" id="demo-image" /></div>
</div>
</body>
</html>



Post a Comment

0 Comments