MediaWiki:BibleGet.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 27: Line 27:
$bGetTIP.css({"top":top,"left":left});
$bGetTIP.css({"top":top,"left":left});
if($bGetTIP.is(':offscreen') ){
if($bGetTIP.is(':offscreen') ){
console.log('This element was offscreen!');
//how far off the bottom of the screen are we?
//how far off the bottom of the screen are we?
let rect = $bGetTIP[0].getBoundingClientRect();
let rect = $bGetTIP[0].getBoundingClientRect();
Line 84: Line 85:
let left = $span.offset().left + $span.outerWidth() + 15;
let left = $span.offset().left + $span.outerWidth() + 15;
$bGetTIP.css({"top":top,"left":left});
$bGetTIP.css({"top":top,"left":left});
if($bGetTIP.is(':offscreen') ){
console.log('This element was offscreen!');
//how far off the bottom of the screen are we?
let rect = $bGetTIP[0].getBoundingClientRect();
let excessHeight = (rect.y + rect.height) - window.innerHeight;
//if this amount is less than the distance from the top of the screen,
// then let's just move our div up by that much
if(excessHeight < rect.y){
let newTop = top - excessHeight;
$bGetTIP.css({"top":newTop});
}
}
});
});