jQuery UI Draggable pushed upwards on mousedown in IE11
HTML
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<body>
<div id="containment">
<div id="draggable">
<div id="handle"></div>
</div>
</div>
</body>
CSS
html,
body {
height: 100%;
margin: 0px;
width: 100%;
}
#containment {
border: 1px solid black;
height: 300px;
margin: 50px;
overflow: hidden;
position: absolute;
width: 300px;
}
#draggable {
background-color: red;
height: 150px;
left: 0px;
position: absolute;
top: 0px;
width: 150px;
}
#handle {
background-color: Blue;
height: 50px;
left: 33%;
position: absolute;
top: 33%;
width: 50px;
}
JavaScript
$(function() {
var containmentRect = $('#containment')
.get(0)
.getBoundingClientRect();
var draggableRect = $('#draggable')
.get(0)
.getBoundingClientRect();
var handleRect = $('#handle')
.get(0)
.getBoundingClientRect();
var redBorderSize = (draggableRect.width - handleRect.width) / 2;
var containment = [
containmentRect.top - redBorderSize,
containmentRect.left - redBorderSize,
containmentRect.right + redBorderSize - draggableRect.width,
containmentRect.bottom + redBorderSize - draggableRect.height
];
$('#draggable').draggable({
containment: containment,
distance: 15,
handle: '#handle',
scroll: false
});
});