@@ -405,23 +405,27 @@ $(function () {
405
405
/* _variables.scss & _navigation.scss - .tooltip:before */
406
406
const toolTipArrowHalfSize = 10 ; /* $tooltip-arrow-half-size */
407
407
var tooltip = null ;
408
+ var tooltipRenderer = null ;
408
409
var tooltipTarget = null ;
409
410
var elementUnderCursor = null ;
410
411
var shouldShowTooltip = false ;
411
412
var showTimeoutFuncID ;
412
413
var hideTimeoutFuncID ;
413
414
414
415
function setTooltipPos ( event , tooltipTarget , alignment ) {
415
- const mouseX = event . clientX ;
416
416
const rect = tooltipTarget . getBoundingClientRect ( ) ;
417
417
var computedTargetStyle = window . getComputedStyle ( tooltipTarget ) ;
418
418
var lineHeight = parseFloat ( computedTargetStyle . getPropertyValue ( 'line-height' ) ) ;
419
- // Size is still not yet calculated correctly here
420
- var tooltipRect = tooltip . getBoundingClientRect ( ) ;
421
- var computedTooltipStyle = window . getComputedStyle ( tooltip ) ;
422
- var tooltipWidth = parseFloat ( computedTooltipStyle . getPropertyValue ( 'width' ) ) ;
419
+ // NOTE: The content of the targeted tooltip is still not yet calculated correctly here, as it is invisible, and getting visible is animated multiple ways
420
+ // use, the always visible, not animated at all, but offscreen pair of it (tooltipRenderer) for rendered size calculations.
421
+ // To get this work all the animation styles must be removed in the css (_navigations.scss) for #tooltipRenderer
422
+ // TODO: Now we have the correct tooltip content via teh tooltipRenderer trick.
423
+ // Prevent tooltip overflow on window edges in all directions.
424
+ var tooltipRect = tooltipRenderer . getBoundingClientRect ( ) ;
425
+ var tooltipWidth = tooltipRect . width ;
423
426
var pos = new DOMPoint ( ) ;
424
427
428
+ const mouseX = event . clientX ;
425
429
var xShift = ( alignment == 'tooltip-align-left' ? tooltipWidth : ( alignment == 'tooltip-align-center' ? tooltipWidth / 2 : 0 ) ) ;
426
430
pos . x = mouseX ; // Use now mouse X instead - Math.max(0, pos.x + document.documentElement.scrollLeft + rect.left);
427
431
pos . x -= xShift ;
@@ -445,34 +449,30 @@ $(function () {
445
449
}
446
450
447
451
function showTooltip ( event , tooltipText , alignment , isFullPageContent ) {
452
+
448
453
tooltip . innerHTML = tooltipText . innerHTML ;
454
+ tooltipRenderer . innerHTML = tooltipText . innerHTML ;
449
455
450
- // FIXME: try to limit the tooltip height not to overflow at bottom
451
- // This
452
- // - still has no scroll bar in the inner content
453
- // - screws up the arrow bellow
454
- // var firstDiv = tooltip.querySelector("div");
455
- // if (firstDiv) {
456
- // tooltip.style.maxHeight = window.innerHeight + 'px';
457
- // tooltip.style.overflowY = 'hidden';
458
- // firstDiv.style.overflowY = 'auto';
459
- // }
460
-
461
- if ( isFullPageContent )
456
+ if ( isFullPageContent ) {
462
457
tooltip . classList . add ( "full-content-tooltip" ) ;
463
- else
458
+ tooltipRenderer . classList . add ( "full-content-tooltip" ) ;
459
+ }
460
+ else {
464
461
tooltip . classList . remove ( "full-content-tooltip" ) ;
462
+ tooltipRenderer . classList . remove ( "full-content-tooltip" ) ;
463
+ }
465
464
tooltip . classList . remove ( 'tooltip-align-left' , 'tooltip-align-center' , 'tooltip-align-right' ) ;
465
+ tooltipRenderer . classList . remove ( 'tooltip-align-left' , 'tooltip-align-center' , 'tooltip-align-right' ) ;
466
466
tooltip . classList . add ( alignment ) ;
467
+ tooltipRenderer . classList . add ( alignment ) ;
467
468
468
- setTooltipPos ( event , tooltipTarget , alignment )
469
-
470
469
shouldShowTooltip = true ;
471
470
472
471
clearTimeout ( hideTimeoutFuncID ) ;
473
472
clearTimeout ( showTimeoutFuncID ) ;
474
473
showTimeoutFuncID = setTimeout ( function ( ) {
475
474
if ( shouldShowTooltip ) {
475
+ setTooltipPos ( event , tooltipTarget , alignment ) ;
476
476
tooltip . classList . add ( 'visible' ) ;
477
477
}
478
478
} , 100 ) ;
@@ -504,6 +504,7 @@ $(function () {
504
504
function addContentTooltips ( ) {
505
505
var tooltipElements = document . querySelectorAll ( '.content-tooltip' ) ;
506
506
tooltip = document . getElementById ( 'tooltip' ) ;
507
+ tooltipRenderer = document . getElementById ( 'tooltipRenderer' ) ;
507
508
hideTooltip ( ) ;
508
509
509
510
tooltipElements . forEach ( function ( element ) {
@@ -527,13 +528,9 @@ $(function () {
527
528
newContent = newContent . innerHTML ;
528
529
newContent = alterContentForTooltip ( newContent , url . isFullPageContent ) ;
529
530
530
- if ( newContent . length > 0 ) {
531
- // cache for reuse
532
- tooltipText . innerHTML = newContent ;
533
- setTimeout ( ( ) => {
534
- // Get the bounding client rect after rendering
535
- showTooltip ( event , tooltipText , alignment , isFullPageContent ) ;
536
- } , 0 ) ;
531
+ if ( newContent . length > 0 ) {
532
+ tooltipText . innerHTML = newContent ; // cache for reuse
533
+ showTooltip ( event , tooltipText , alignment , isFullPageContent ) ;
537
534
}
538
535
else {
539
536
// Quick navigation from another link with tooltip to this link would keep alive the previous tooltip
0 commit comments