-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from contentstack/EB-1884-element-hover-outline
Added outline to hovered elements
- Loading branch information
Showing
4 changed files
with
52 additions
and
7 deletions.
There are no files selected for viewing
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,21 @@ | ||
|
||
/** | ||
* Adds a hover outline to the target element. | ||
* @param targetElement - The element to add the hover outline to. | ||
* @returns void | ||
*/ | ||
export function addHoverOutline( | ||
targetElement: Element | ||
): void { | ||
|
||
const targetElementDimension = targetElement.getBoundingClientRect(); | ||
|
||
const hoverOutline = document.querySelector<HTMLDivElement>(".visual-editor__hover-outline"); | ||
|
||
if (hoverOutline) { | ||
hoverOutline.style.top = `${targetElementDimension.top + window.scrollY}px`; | ||
hoverOutline.style.left = `${targetElementDimension.left}px`; | ||
hoverOutline.style.width = `${targetElementDimension.width}px`; | ||
hoverOutline.style.height = `${targetElementDimension.height}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
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