Due to my small amount of experience with JavaScript I didn't realise that the callback could in fact modify the position, even though it doesn't return
anything. This is because in JS apparently parameters are by default passed by reference.
Here's a working code:
// Couldn't figure out a way to use the coordinates
// that jQuery also stores, so let's record our own.
var click = {
x: 0,
y: 0
};
$('.draggable').draggable({
start: function(event) {
click.x = event.clientX;
click.y = event.clientY;
},
drag: function(event, ui) {
// This is the parameter for scale()
var zoom = 1.5;
var original = ui.originalPosition;
// jQuery will simply use the same object we alter here
ui.position = {
left: (event.clientX - click.x + original.left) / zoom,
top: (event.clientY - click.y + original.top ) / zoom
};
}
});