MooResize adds three handles to any image or other DOM Element. With these handles, you can resize your element on a easy way. It has three events, onStart, onResize and onComplete so it is very flexible too. Also it is very easy to set a ratio by the setRatio method.
First you have to include the javascript file in the head of your document
<script src="../Source/MooResize.js" type="text/javascript"></script>
In the body
<img id="resizeMe" src="image.jpg" alt="Look, you can resize me" />
Then add the following javascript
new resize = new MooResize('resizeMe');
And you're done!
var resize = new MooResize('img1',{
handleSize: 15,
handleStyle: {
background: 'blue'
},
onStart: function(){
document.id(this).setStyle('opacity',0.5);
},
onComplete: function(size){
document.id(this).setStyle('opacity',1);
alert(size.x+' '+size.y);
},
minSize: {
x: 100,
y: 50
}
});
new MooResize(element[,options]);
Set the size of the element (including the new position of the handles)
resize.setSize(width,height);
// Or
resize.setSize({x: 500, y: 400});
Get the size of the element
resize.getSize(); // {x: 256, y: 643}
Set a ratio
resize.ratio(ratio);
Get the current ratio as width/height
resize.getRatio(); // 1.25
Remove the handles
resize.dispose();
Get your element back
document.id(resize);
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus