-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4ef209
commit 153ac58
Showing
7 changed files
with
117 additions
and
124 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { setPositionRelativeTo } from "../../util/setPositionRelativeTo"; | ||
import { TourStep } from "./steps"; | ||
|
||
/** | ||
* Sets the position of the element relative to the TourStep | ||
* @api private | ||
*/ | ||
export const setPositionRelativeToStep = ( | ||
relativeElement: HTMLElement, | ||
element: HTMLElement, | ||
step: TourStep, | ||
padding: number | ||
) => { | ||
setPositionRelativeTo( | ||
relativeElement, | ||
element, | ||
step.element as HTMLElement, | ||
step.position === "floating" ? 0 : padding | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import getOffset from "./getOffset"; | ||
import isFixed from "./isFixed"; | ||
import { removeClass, addClass } from "./className"; | ||
import setStyle from "./setStyle"; | ||
|
||
/** | ||
* Sets the position of the element relative to the target element | ||
* @api private | ||
*/ | ||
export const setPositionRelativeTo = ( | ||
relativeElement: HTMLElement, | ||
element: HTMLElement, | ||
targetElement: HTMLElement, | ||
padding: number | ||
) => { | ||
if (!element || !relativeElement || !targetElement) { | ||
return; | ||
} | ||
|
||
// If the target element is fixed, the tooltip should be fixed as well. | ||
// Otherwise, remove a fixed class that may be left over from the previous | ||
// step. | ||
if (targetElement instanceof Element && isFixed(targetElement)) { | ||
addClass(element, "introjs-fixedTooltip"); | ||
} else { | ||
removeClass(element, "introjs-fixedTooltip"); | ||
} | ||
|
||
const position = getOffset(targetElement, relativeElement); | ||
|
||
//set new position to helper layer | ||
setStyle(element, { | ||
width: `${position.width + padding}px`, | ||
height: `${position.height + padding}px`, | ||
top: `${position.top - padding / 2}px`, | ||
left: `${position.left - padding / 2}px`, | ||
}); | ||
}; |