Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

fix: prevent display of highlight area with height/width 0 #608

Merged
merged 1 commit into from
Sep 16, 2018
Merged
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
13 changes: 6 additions & 7 deletions src/preview/element-area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,16 @@ export class ElementArea {
this.isVisible = true;
}

public write(element: HTMLElement, context: { scrollPositon: Types.Point }): void {
if (!this.element) {
return;
}

const rect = this.element.getBoundingClientRect();
public write(element: HTMLElement, _: { scrollPositon: Types.Point }): void {
const rect = this.element
? this.element.getBoundingClientRect()
: { top: 0, left: 0, width: 0, height: 0 };

element.style.top = `${rect.top}px`;
element.style.left = `${rect.left}px`;
element.style.width = `${rect.width}px`;
element.style.height = `${rect.height}px`;
element.style.display = this.isVisible ? 'block' : 'none';

element.style.display = !this.isVisible || (!rect.height && !rect.width) ? 'none' : 'block';
}
}