-
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
8fed9d4
commit c61ef27
Showing
14 changed files
with
200 additions
and
97 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
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 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,30 @@ | ||
import { deleteCookie, getCookie, setCookie } from "../../util/cookie"; | ||
|
||
const dontShowAgainCookieValue = "true"; | ||
|
||
/** | ||
* Set the "Don't show again" state | ||
* | ||
* @api private | ||
*/ | ||
export function setDontShowAgain( | ||
dontShowAgain: boolean, | ||
cookieName: string, | ||
cookieDays: number | ||
) { | ||
if (dontShowAgain) { | ||
setCookie(cookieName, dontShowAgainCookieValue, cookieDays); | ||
} else { | ||
deleteCookie(cookieName); | ||
} | ||
} | ||
|
||
/** | ||
* Get the "Don't show again" state from cookies | ||
* | ||
* @api private | ||
*/ | ||
export function getDontShowAgain(cookieName: string): boolean { | ||
const dontShowCookie = getCookie(cookieName); | ||
return dontShowCookie !== "" && dontShowCookie === dontShowAgainCookieValue; | ||
} |
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 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,48 @@ | ||
import getOffset from "../../util/getOffset"; | ||
import isFixed from "../../util/isFixed"; | ||
import addClass from "../../util/addClass"; | ||
import removeClass from "../../util/removeClass"; | ||
import setStyle from "../../util/setStyle"; | ||
import { TourStep } from "./steps"; | ||
import { Tour } from "./tour"; | ||
import { fixedTooltipClassName } from "./classNames"; | ||
|
||
/** | ||
* Update the position of the helper layer on the screen | ||
* | ||
* @api private | ||
*/ | ||
export default function setHelperLayerPosition( | ||
tour: Tour, | ||
step: TourStep, | ||
helperLayer: HTMLElement | ||
) { | ||
if (!helperLayer || !step) return; | ||
|
||
const elementPosition = getOffset( | ||
step.element as HTMLElement, | ||
tour.getTargetElement() | ||
); | ||
let widthHeightPadding = tour.getOption("helperElementPadding"); | ||
|
||
// 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 (step.element instanceof Element && isFixed(step.element)) { | ||
addClass(helperLayer, fixedTooltipClassName); | ||
} else { | ||
removeClass(helperLayer, fixedTooltipClassName); | ||
} | ||
|
||
if (step.position === "floating") { | ||
widthHeightPadding = 0; | ||
} | ||
|
||
//set new position to helper layer | ||
setStyle(helperLayer, { | ||
width: `${elementPosition.width + widthHeightPadding}px`, | ||
height: `${elementPosition.height + widthHeightPadding}px`, | ||
top: `${elementPosition.top - widthHeightPadding / 2}px`, | ||
left: `${elementPosition.left - widthHeightPadding / 2}px`, | ||
}); | ||
} |
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
Oops, something went wrong.