below here is some javascript code to be able to drag elements around the page. How would I be able to also resize the div without moving it around. For example exclude 5px from the bottom right of the div or something like that.
dragElement(document.querySelector(".dragTime"));
dragElement(document.querySelector("#full-date"));
dragElement(document.querySelector("#stocks"));
function dragElement(ele) {
var pos1 = 0,
pos2 = 0,
pos3 = 0,
pos4 = 0;
if (document.querySelector(ele.id + "header")) {
document.getElementById(
ele.id + "header"
).onmousedown = dragMouseDown;
}
else {
ele.onmousedown = dragMouseDown;
}
function dragMouseDown(e) {
e = e || window.event;
e.preventDefault();
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = closeDragElement;
document.onmousemove = elementDrag;
}
function elementDrag(e) {
e = e || window.event;
e.preventDefault();
pos1 = pos3 - e.clientX ;
pos2 = pos4 - e.clientY ;
pos3 = e.clientX;
pos4 = e.clientY;
ele.style.top = ele.offsetTop - pos2 + "px";
ele.style.left = ele.offsetLeft - pos1 + "px";
}
function closeDragElement() {
document.onmouseup = null;
document.onmousemove = null;
}
}
Any help would be great please and thanks