1
0
Fork 0

hovercard: better placement management

This commit is contained in:
rabuzarus 2016-05-06 17:32:07 +02:00
parent 047722dc37
commit 0ab7a210f9

View file

@ -62,7 +62,16 @@ $(document).ready(function(){
if(data) { if(data) {
targetElement.popover({ targetElement.popover({
html: true, html: true,
placement: 'auto', placement: function () {
// Calculate the placement of the the hovercard (if top or bottom)
// The placement depence on the distance between window top and the element
// which triggers the hover-card
var get_position = $(targetElement).offset().top - $(window).scrollTop();
if (get_position < 270 ){
return "bottom";
}
return "top";
},
trigger: 'manual', trigger: 'manual',
template: '<div class="popover hovercard" data-card-created="' + timeNow + '"><div class="arrow"></div><div class="popover-content hovercard-content"></div></div>', template: '<div class="popover hovercard" data-card-created="' + timeNow + '"><div class="arrow"></div><div class="popover-content hovercard-content"></div></div>',
content: data content: data