MediaWiki:BibleGet.js: differenze tra le versioni

nessun oggetto della modifica
Nessun oggetto della modifica
Nessun oggetto della modifica
Riga 36: Riga 36:
if(!$bGetTIP.hasClass('sticky')){
if(!$bGetTIP.hasClass('sticky')){
if(excessHeight > 0 && excessHeight < rect.y){
if(excessHeight > 0 && excessHeight < rect.y){
console.log('This element was off the bottom of the screen');
let newTop = top - excessHeight;
let newTop = top - excessHeight;
$bGetTIP.css({"top":newTop});
$bGetTIP.css({"top":newTop});
}
}
if(excessWidth > 0 && excessWidth < rect.x){
if(excessWidth > 0 && excessWidth < rect.x){
console.log('This element was off the left of the screen');
let newLeft = left - excessWidth;
let newLeft = left - excessWidth;
$bGetTIP.css({"left":newLeft});
$bGetTIP.css({"left":newLeft});
Riga 107: Riga 109:
$bGetTIP.css({"top":top,"left":left});
$bGetTIP.css({"top":top,"left":left});
if($bGetTIP.hasClass('sticky') || $bGetTIP.is(':offscreen') ){
if($bGetTIP.hasClass('sticky') || $bGetTIP.is(':offscreen') ){
console.log('This element was offscreen!');
//are we off the bottom or the right side of the screen, and how much?
//how far off the bottom of the screen are we?
let rect = $bGetTIP[0].getBoundingClientRect();
let rect = $bGetTIP[0].getBoundingClientRect();
let excessHeight = (rect.y + rect.height) - window.innerHeight;
let excessHeight = (rect.y + rect.height) - window.innerHeight;
let excessWidth = (rect.x + rect.width) - window.innerWidth;
//if this amount is less than the distance from the top of the screen,
//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
// then let's just move our div up by that much
if(!$bGetTIP.hasClass('sticky') && excessHeight < rect.y){
if(!$bGetTIP.hasClass('sticky')){
let newTop = top - excessHeight;
if(excessHeight > 0 && excessHeight < rect.y){
$bGetTIP.css({"top":newTop});
console.log('This element was off the bottom of the screen');
let newTop = top - excessHeight;
$bGetTIP.css({"top":newTop});
}
if(excessWidth > 0 && excessWidth < rect.x){
console.log('This element was off the left of the screen');
let newLeft = left - excessWidth;
$bGetTIP.css({"left":newLeft});
}
} else {
} else {
if(!$bGetTIP.hasClass('sticky')){
if(!$bGetTIP.hasClass('sticky')){