Skip to content

Commit

Permalink
Update Overlay.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
manishPh authored Oct 13, 2023
1 parent ad7dbed commit bdae51c
Showing 1 changed file with 43 additions and 5 deletions.
48 changes: 43 additions & 5 deletions src/components/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,56 @@ export default class JoyrideOverlay extends React.Component<OverlayProps, State>
const element = getElement(target);
const elementRect = getClientRect(element);
const isFixedTarget = hasPosition(element);
const top = getElementPosition(element, spotlightPadding, disableScrollParentFix);

let overridenHeight;

if (styles.spotlight.height) {
overridenHeight =
typeof styles.spotlight.height === 'number'
? styles.spotlight.height
: Number(parseInt(styles.spotlight.height, 10));
}

let overridenWidth;

if (styles.spotlight.width) {
overridenWidth =
typeof styles.spotlight.width === 'number'
? styles.spotlight.width
: Number(parseInt(styles.spotlight.width, 10));
}

let overridenLeft;

if (styles.spotlight.left) {
overridenLeft =
typeof styles.spotlight.left === 'number'
? styles.spotlight.left
: Number(parseInt(styles.spotlight.left, 10));
}

let overridenTop;

if (styles.spotlight.top) {
overridenTop =
typeof styles.spotlight.top === 'number'
? styles.spotlight.top
: Number(parseInt(styles.spotlight.top, 10));
}

const top =
overridenTop ?? getElementPosition(element, spotlightPadding, disableScrollParentFix);

return {
height: Math.round((elementRect?.height ?? 0) + spotlightPadding * 2),
left: Math.round((elementRect?.left ?? 0) - spotlightPadding),
...(isLegacy() ? styles.spotlightLegacy : styles.spotlight),
height: Math.round((overridenHeight ?? elementRect?.height ?? 0) + spotlightPadding * 2),
left: Math.round((overridenLeft ?? elementRect?.left ?? 0) - spotlightPadding),
opacity: showSpotlight ? 1 : 0,
pointerEvents: spotlightClicks ? 'none' : 'auto',
position: isFixedTarget ? 'fixed' : 'absolute',
top,
transition: 'opacity 0.2s',
width: Math.round((elementRect?.width ?? 0) + spotlightPadding * 2),
...(isLegacy() ? styles.spotlightLegacy : styles.spotlight),
width: overridenWidth || Math.round((elementRect?.width ?? 0) + spotlightPadding * 2),
} satisfies React.CSSProperties;
}

Expand Down

0 comments on commit bdae51c

Please sign in to comment.