mine magic zoom
by cleaver
JavaScript
$('#popup-layer').on('mousemove', '#lightbox .zoom-full:not(.loading)', function(e) {
var offtop = parseInt($("#lightbox").css("top"));
var offleft = parseInt($("#lightbox").css("left"));
imageWidth = parseInt($(this).find("img").width()),
imageHeight = parseInt($(this).find("img").height());
rY = (imageHeight - 600) / 600;
rX = (imageWidth - 854) / 854;
eY = -((e.pageY - offtop) * rY),
eX = -((e.pageX - offleft) * rX);
if(imageHeight > 600) $("#lightbox .zoom-full img").css({"top":"auto","margin-top":eY});
if(imageWidth > 854) $("#lightbox .zoom-full img").css({"left":"auto","margin-left":eX});
});