I'm developing a site that uses isotope to lay out a number of items in grid form.
I'm implementing a rollover system that displays popup boxes with additional info.
The issue is that on narrow screens the popups flow off the screen to the right, example here:
https://jsfiddle.net/wsgfuace/2/
Ideally when rolling over the right half of the screen I'd like the popups to anchor to the lower right hand corner instead of the lower left.
How is this possible please?
I found this code which looks like it could potentially work but am unable to implement it successfully:
$(function() {
$('.item-s').hover(function() {
var win=$(this).find('.big-s:visible');
if(win.length>0) {
var screenwidth=$('body').width();
var width=win.width();
var pos=win.position();
var rightpos=width+pos.left;
if(rightpos>screenwidth) {
var moveleft=rightpos-screenwidth;
win.css('margin-left','-'+moveleft+'px');
} else {
win.css('margin-left','0px');
}
}
});
});