JavaScript:
var box = document.querySelector(".container");
var grab = document.querySelector(".container img");
var store = { move: false };
grab.addEventListener("mousedown", function (event) {
store.move = true;
store.startY = event.pageY + box.scrollTop;
store.startX = event.pageX + box.scrollLeft;
});
document.addEventListener("mousemove", function(event) {
store.y = event.pageY;
store.x = event.pageX;
if (store.move == true) {
box.scrollTop = store.startY - store.y;
box.scrollLeft = store.startX - store.x;
event.preventDefault();
}
});
document.addEventListener("mouseup", function(event) {
store.move = false;
});