Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/test-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
footer: { statements: '100%', branches: '100%', functions: '100%', lines: '100%' },
form: { statements: '2.8%', branches: '0%', functions: '0%', lines: '2.96%' },
grid: { statements: '100%', branches: '100%', functions: '100%', lines: '100%' },
guide: { statements: '3.46%', branches: '0%', functions: '0%', lines: '3.77%' },
guide: { statements: '94.38%', branches: '87.15%', functions: '100%', lines: '96.34%' },
hooks: { statements: '69.04%', branches: '34.32%', functions: '71.87%', lines: '70%' },
image: { statements: '97.72%', branches: '100%', functions: '92.3%', lines: '97.61%' },
imageViewer: { statements: '8.47%', branches: '2.87%', functions: '0%', lines: '8.84%' },
Expand Down
16 changes: 13 additions & 3 deletions src/guide/Guide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ const Guide: FC<GuideProps> = (originProps) => {

// 设置高亮层的位置
const setHighlightLayerPosition = (highlightLayer: HTMLElement, isReference = false) => {
if (!highlightLayer) return;

let { top, left } = getRelativePosition(currentHighlightLayerElm.current);
let { width, height } = currentHighlightLayerElm.current.getBoundingClientRect();
const highlightPadding = getCurrentCrossProps('highlightPadding');
Expand Down Expand Up @@ -181,7 +183,11 @@ const Guide: FC<GuideProps> = (originProps) => {
width: '100vw',
};

referenceElements.forEach((elem) => setStyle(elem, style));
referenceElements.forEach((elem) => {
if (elem) {
setStyle(elem, style);
}
});
};

const showPopoverGuide = () => {
Expand Down Expand Up @@ -221,8 +227,12 @@ const Guide: FC<GuideProps> = (originProps) => {
};

const destroyGuide = () => {
highlightLayerRef.current?.parentNode.removeChild(highlightLayerRef.current);
overlayLayerRef.current?.parentNode.removeChild(overlayLayerRef.current);
if (highlightLayerRef.current?.parentNode) {
highlightLayerRef.current.parentNode.removeChild(highlightLayerRef.current);
}
if (overlayLayerRef.current?.parentNode) {
overlayLayerRef.current.parentNode.removeChild(overlayLayerRef.current);
}
removeClass(document.body, LOCK_CLASS);
};

Expand Down
Loading
Loading