javascript make element resizalbe code example
Example 1: resizing div js
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Resizable - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<style>
#resizable { width: 150px; height: 150px; padding: 0.5em; }
#resizable h3 { text-align: center; margin: 0; }
</style>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#resizable" ).resizable();
} );
</script>
</head>
<body>
<div id="resizable" class="ui-widget-content">
<h3 class="ui-widget-header">Resizable</h3>
</div>
</body>
</html>
Example 2: js resize div with mouse
bottom-right: new_width = element_original_width + (mouseX - original_mouseX) new_height = element_original_height + (mouseY - original_mouseY)bottom-left: new_width = element_original_width - (mouseX - original_mouseX) new_height = element_original_height + (mouseY - original_mouseY) new_x = element_original_x - (mouseX - original_mouseX)top-right: new_width = element_original_width + (mouseX - original_mouseX) new_height = element_original_height - (mouseY - original_mouseY) new_y = element_original_y + (mouseY - original_mouseY)top-left: new_width = element_original_width - (mouseX - original_mouseX) new_height = element_original_height - (mouseY - original_mouseY) new_x = element_original_x + (mouseX - original_mouseX) new_y = element_original_y + (mouseY - original_mouseY)