Reputation: 2173
Anyone have a good jquery Image Preview plugin. Been looking but havent found anything good. The requirements are:
I have been using imgPreview but it doesn't offer the collision. Any others?
Thanks!
Upvotes: 0
Views: 811
Reputation: 2173
Thanks @mrtsherman , its not quite what i used but it got me thinking. I did:
$('.a').imgPreview(
{
preloadImages : false,
onLoad: function()
{
if ($(this).parent().position().left > 600)
{
var pLeft = $(this).parent().position().left;
var pTop = $(this).parent().position().top;
var width = $(this).parent().width();
pLeft = pLeft - width;
$(this).offset({top: pTop, left: pLeft});
}
else
{
var pLeft = $(this).parent().position().left;
var pTop = $(this).parent().position().top;
$(this).offset({top: pTop, left: pLeft});
}
}
}
)
Upvotes: 0
Reputation: 39872
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', '');
}
});
Upvotes: 1