usablica / intro.js

Lightweight, user-friendly onboarding tour library
http://introjs.com
Other
22.8k stars 2.59k forks source link

Incorrect position bottom-middle-aligned #1842

Closed UMSF-K13-3-Sahan closed 1 year ago

UMSF-K13-3-Sahan commented 1 year ago

Description

Step`s tooltip with position: 'bottom-middle-aligned' aligned for left side

Expected Behavior

Step`s tooltip with position: 'bottom-middle-aligned' middle aligned

Example (recommended)

Example

Environment (optional)

Latest version of introJS (6.0). Latest versions of Firefox and Chrome.

UMSF-K13-3-Sahan commented 1 year ago

I think this happend cuz in _checkLeft you set correct style.right for middle align

export default function checkLeft(
  targetOffset,
  tooltipLayerStyleRight,
  tooltipOffset,
  tooltipLayer
) {
  if (
    targetOffset.left +
      targetOffset.width -
      tooltipLayerStyleRight -
      tooltipOffset.width <
    0
  ) {
    // off the left side of the window
    tooltipLayer.style.left = `${-targetOffset.left}px`;
    return false;
  }
**tooltipLayer.style.right = `${tooltipLayerStyleRight}px`;** !!!!!
  return true;
}

tooltipLayer.style.right = ${tooltipLayerStyleRight}px;

and then right after it in placeTooltip.js 346 you set null to style.right.

case "bottom-middle-aligned":
      arrowLayer.className = "introjs-arrow top-middle";
      // a fix for middle aligned hints
      if (hintMode) {
        tooltipLayerStyleLeftRight += 5;
      }

      if (
        checkLeft(
          targetOffset,
          tooltipLayerStyleLeftRight,
          tooltipOffset,
          tooltipLayer
        )
      ) {
       **tooltipLayer.style.right = null;** !!!!
        checkRight(
          targetOffset,
          tooltipLayerStyleLeftRight,
          tooltipOffset,
          windowSize,
          tooltipLayer
        );
      }
      tooltipLayer.style.top = `${targetOffset.height + 20}px`;
      break;

tooltipLayer.style.right = null;

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.