$(function() {
var b=$('.box');
var ib=$('.infobox');
b.draggable({stop: showinfo});
b.resizable({stop: showinfo});
//double click on resize icon to toggle scale function
b.transformable( {
rotateStop: showinfo,
skewStop: showinfo,
scaleStop: showinfo,
rotate: showrotate,
scale: constrainscale
});
//containment is still a bit expiramental
$('#box3').draggable('option','containment','parent')
.transformable('option','containment',true)
.resizable('option','containment','parent');
$('.box2').find('.ui-resizable-handle').trigger('dblclick');
function constrainscale(e,ui) {
//uncomment to see how you can set value to constrain size
//if (ui.scalex<0.5) ui.scalex=0.5;
//if (ui.scaley<0.5) ui.scaley=0.5;
}
function showrotate(e,ui) {
$('#rotate').html(ui.angle.rad);
//uncomment this to see how you can set the value to constrain angle
//if(ui.angle.rad>1)ui.angle.rad=1;if(ui.angle.rad<-1) ui.angle.rad=-1;
}
function showinfo (e,ui) {
var u=$(this).getTransform();
var o=$(this).tOffset();
function xytostr(c) {
return(parseInt(c.x)+','+parseInt(c.y));
}
ib.html(
'Div Transformation Info:<ul>Current Matrix:<li>'
+ $(this).matrixToArray()+'</li></ul><ul>Rotation:<li id="rotate">'
+u.rotate+'</li></ul><ul>Skew:<li>'
+u.skew+"</li></ul><ul>Scale:<li>"
+u.scale+'</li></ul><ul>Offset:<li>'
+'left:'+parseInt(o.left)+", top:"+parseInt(o.top)
+', right:'+parseInt(o.right)+'bottom:'+parseInt(o.bottom)
+'</li></ul>'
+'<ul>Corners:<li>lt:'+xytostr(o.corners[0])
+', rt:'+xytostr(o.corners[1])
+', rb:'+xytostr(o.corners[2])
+', lb:'+xytostr(o.corners[3])
);
}
$('#sl').slider({
min: 10,
max:...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.