JSFiddle - React, Tailwind, and code Playground
HTML
<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>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<div class="img" id="img">
<div class="anchor" id="anchor"></div>
</div>
CSS
.img
{
position: relative;
width: 150px; height: 150px;
min-width:100px; min-height: 50px;
max-width: 300px; max-height: 300px;
background: url(https://lorempixel.com/300/300/city/) center no-repeat;
background-size: 100% 100%;
//background-size: cover; /* cover - С сохранением пропорций */
}
.anchor
{
position: absolute;
right: 0; bottom: 0;
width: 20px; height: 20px;
background-color: red;
cursor: nw-resize;
}
JavaScript
var anchor = document.getElementById("anchor");
var img = document.getElementById("img");
var positionStart = {x: 0, y: 0, w: 0, h: 0};
function Start(e)
{
positionStart.x = e.screenX;
positionStart.y = e.screenY;
positionStart.w = img.offsetWidth;
positionStart.h = img.offsetHeight;
document.addEventListener("mousemove", Move);
document.addEventListener("mouseup", End);
}
function Move(e)
{
img.style.width = positionStart.w + (e.screenX - positionStart.x) + "px";
img.style.height = positionStart.h + (e.screenY - positionStart.y) + "px";
}
function End()
{
document.removeEventListener('mousemove', Move);
document.removeEventListener("mouseup", End);
}
anchor.addEventListener("mousedown", Start);