You could continue using imgpreview and make use of the callback onShow
. This is detailed in the plugins documentation. The callback contains a reference to the container which you can then alter the CSS properties of to position.
http://james.padolsey.com/javascript/new-jquery-plugin-imgpreview/
Set container to hidden and then position it yourself in the callback. From looking at examples the containers are absolutely positioned, so you just need to modify the top and left properties to get them on screen.
pseudocode:
$('a').imgPreview({
imgCSS: {
visible: 'hidden'
},
onShow: function(link){
//is element visible?
$(this).css('top', xx).css('left', yy).css('visible', '');
}
});
Is element visible on screen?