Well, here's my first ever question - and sadly a newbie - but if i take you through my thinking i'm hoping someone can help me extend my skills and get this layout sorted?
- i'm using bootstrap
- in one page i have a series of divs that work perfectly with isotope ( + infinite scroll )
- as a user hovers over each div, i want a popover to display more info about the element
- this i can get to work using
data-container="body"
So far so good..
Next i found out the correct placement of each of the elements using:
$('#container').isotope({
itemSelector: '.item',
itemPositionDataEnabled: true
})
// log position of each item
.find('.item').each(function(){
var item_position = $(this).data('isotope-item-position');
console.log('item position is x: ' + item_position.x + ',
y: ' + item_position.y);});
(from http://isotope.metafizzy.co/docs/options.html#itempositiondataenabled )
So now the issue i've come up against is how to affect the placement of the popover dependent on the values the isotope log is giving me - thus if a element is placed to the far right of the viewport - then the popover displays to the left or below (and not hidden out of sight).
Appreciate any help and guidance on this - pretty much tried any answers i've found here but i can't get them to work..
(I've put together a quick (and for some reason the isotope aint working) fiddle to try to explain what i am trying to achieve here: http://jsfiddle.net/watcher/Kv8Bw/1/ )
Next attempt post @Bass help :
@bass - Appreciate the help - but i think my js knowledge is letting me down here (included some logic from another answer - [link]Changing the position of Bootstrap popovers based on the popover's X position in relation to window edge? ) have been pluggin away at this:
$("#popover").popover({
trigger: "hover focus"
});
var tmp = $.fn.popover.Constructor.prototype.show;
$.fn.popover.Constructor.prototype.show = function () {
var items = Array('top','bottom','left','right');
var position = $(this).data('isotope-item-position');
if (position.left > 515) {
return "left";
}
if (position.left < 515) {
return "right";
}
if (position.top < 110){
return "bottom";
}
return "top";
}
tmp.call(this);
But my issue is (i think that the isotope is returning the values of ALL my items rather than the one i am hovering over - any suggestions?)