Wondering if anyone can help. I'm using jQuery resizable on a website. I'd like to display the size of the resized/resizable object as a notification style badge using pseudo classes, this should update every time the item is resized. The CSS isn't a problem, it's getting the size data and displaying it I'm having issue with. Any ideas how to pull this off? Any help will be much appreciated. I'm having errors in the snippet below so here's a fiddle that works.
https://jsfiddle.net/adrian_babb/xwaokufj/
<ul id="icon_menu">
<li class="draggable"></li>
</ul>
draggable.ui-resizable:after {
content: "";
position: absolute;
top: -5px;
right: -5px;
font-size: .7em;
background-color: #5f6a72;
color: #ffffff;
width: 20px;
height: 20px;
text-align: center;
line-height: 20px;
border-radius: 50%;
}
<script>
$(document).ready(function($) {
$(".droppable").droppable({
accept: '.draggable',
drop: function(event, ui) {
var $clone = ui.helper.clone();
if (!$clone.is('.inside-droppable')) {
$(this).append($clone.addClass('inside-droppable').draggable({
containment: '.droppable',
scroll: false,
tolerance: 'pointer',
position: 'relative',
}));
$clone.resizable({
aspectRatio: 'true',
ghost: 'true',
handles: 'ne, nw, se, sw',
maxHeight: 200,
maxWidth: 200,
minHeight: 30,
minWidth: 30
});
}
}
});
$(".draggable").draggable({
helper: 'clone',
$(document).ready(function($) {
$(".droppable").droppable({
accept: '.draggable',
drop: function(event, ui) {
var $clone = ui.helper.clone();
if (!$clone.is('.inside-droppable')) {
$(this).append($clone.addClass('inside-droppable').draggable({
containment: '.droppable',
scroll: false,
tolerance: 'pointer',
position: 'relative',
}));
$clone.resizable({
aspectRatio: 'true',
ghost: 'true',
handles: 'ne, nw, se, sw',
maxHeight: 200,
maxWidth: 200,
minHeight: 30,
minWidth: 30
});
}
}
});
$(".draggable").draggable({
helper: 'clone',
revert:"invalid",
scroll: false
});
});
#icon_menu {
width: 200px;
height: auto;
float: right;
}
#icon_menu li {
width: 45px;
height: 45px;
position: relative;
}
.draggable {
width: 45px;
height: 45px;
border-radius: 50%;
background: rgba(127, 214, 236, 0.5);
}
.droppable {
width: 200px;
height: 100px;
border: 1px solid #000000;
float: left;
}
draggable.ui-resizable:after {
content: "";
position: absolute;
top: -5px;
right: -5px;
font-size: .7em;
background-color: #5f6a72;
color: #ffffff;
width: 20px;
height: 20px;
text-align: center;
line-height: 20px;
border-radius: 50%;
}
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<ul id="icon_menu">
<li class="draggable"></li>
</ul>