Created
December 6, 2012 03:12
-
-
Save shibayu36/4221539 to your computer and use it in GitHub Desktop.
jquery resizable keeping aspect ratio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>jQuery Resizable</title> | |
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/base/jquery-ui.css" /> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js"></script> | |
<script src="./jquery-resizable.js"></script> | |
</head> | |
<body> | |
<div id="resizable" style="width: 200px; height: 200px; background-color: yellow;"></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function($) { | |
var $resizable = $('#resizable'); | |
var width = $resizable.width(); | |
var height = $resizable.height(); | |
$resizable.resizable({ | |
aspectRatio: width / height | |
}); | |
$resizable.live("resizestop", function (event, ui) { | |
var size = ui.size; | |
console.log(size.width); | |
console.log(size.height); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment