:
right bottom.left top auto right bottom.
$(this).css({
"left": "auto",
"top": "auto",
"right": $(this).position().right,
"top": $(this).position().top
});
, jQuery position() offset(), left top, .
? - jQuery, :
"right": ($(window).width() - ($(this).offset().left + $(this).outerWidth())),
"bottom": ($(window).height() - ($(this).offset().top + $(this).outerHeight()))
. drag. API Draggable . , reset right bottom drag , left top stop.
, :
drag: function( event, ui ) {
$(this).css({
"right": "auto",
"bottom": "auto"
});
},
stop: function (event, ui) {
$(this).css({
"right": ($(window).width() - ($(this).offset().left + $(this).outerWidth())),
"bottom": ($(window).height() - ($(this).offset().top + $(this).outerHeight())),
"left": "auto",
"top": "auto"
});
}
, , , :
$(function() {
$(".draggable-parent").draggable({
handle: ".draggable-handle",
drag: function( event, ui ) {
$(this).css({
"right": "auto",
"bottom": "auto"
});
},
stop: function (event, ui) {
$(this).css({
"right": ($(window).width() - ($(this).offset().left + $(this).outerWidth())),
"bottom": ($(window).height() - ($(this).offset().top + $(this).outerHeight())),
"left": "auto",
"top": "auto"
});
}
});
$(".draggable-parent .resizable-content").resizable({
minHeight: 100,
minWidth: 100,
handles: "se"
});
$(".min-max").click(function(e) {
e.preventDefault();
$(this).closest("h3").next(".real-content").slideToggle();
$(this).toggleClass("max");
});
});
* {
font-family: 'Open Sans';
font-size: 10pt;
line-height: 1;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.draggable-parent {
border: 2px solid #3c3c3c;
display: inline-block;
position: fixed;
border-radius: 4px;
-moz-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
-o-box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
right: 10px;
bottom: 10px;
}
.draggable-parent .resizable-content {
min-height: 50px;
min-width: 100px;
padding-bottom: 20px;
height: auto !important;
}
.draggable-parent .resizable-content .draggable-handle {
background-color: #3c3c3c;
color: #fff;
font-size: 12.5px;
padding: 5px;
cursor: move;
margin: 0;
position: relative;
padding-right: 25px;
}
.ui-resizable-resizing,
.ui-draggable-dragging {
opacity: 0.75;
}
.min-max {
position: absolute;
width: 14px;
height: 14px;
background: url("https://i.stack.imgur.com/2OQlp.png") -1px -1px #fff;
top: 50%;
right: 3px;
margin-top: -8px;
border-radius: 4px;
}
.min-max.max {
background-image: url("https://i.stack.imgur.com/L9GL9.png");
}
.real-content {
background-color: #f90;
padding: 15px;
}
<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>
<div class="draggable-parent">
<div class="resizable-content">
<h3 class="draggable-handle">Draggable & Collapsable <a href="#" class="min-max"></a></h3>
<div class="real-content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.<br />Fugit corrupti quae quia, perferendis porro voluptas itaque<br />recusandae facilis numquam, eius expedita hic minima<br />accusamus consequuntur voluptate!</p>
</div>
</div>
</div>
Hide result, ! , - , . , , , : draggable - !.
, , .