Last active
January 29, 2023 08:59
-
-
Save peeyush14goyal/8a2240097472ea70bdadce8ced0dee3b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<div className="hovs-banner" id="hovs-banner"> | |
{state && | |
state.nodes && | |
state.nodes.map((x, i) => { | |
return ( | |
<div key={i} className="hovs-main"> | |
<div | |
id={"hovs-main-scroll-comp-" + i.toString()} | |
onMouseEnter={() => handleMouseEnter(i)} | |
> | |
{x} | |
</div> | |
<div | |
className="hovs-hoverComp" | |
id={`hovs-data-hover-node-${i}`} | |
> | |
{state.hover_nodes[i]} | |
</div> | |
</div> | |
); | |
})} | |
</div> |
This file contains hidden or 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
const handleMouseEnter = (index) => { | |
const ele = document.getElementById( | |
"hovs-main-scroll-comp-" + index.toString() | |
); | |
const ban_div = document.getElementById("hovs-banner"); | |
const view_ele = document.getElementById("hovs-data-hover-node-" + index); | |
if (view_ele && ele && ban_div) { | |
view_ele.style.top = ele.offsetTop + state.hover_pos_y + "px"; | |
view_ele.style.left = | |
ele.offsetLeft - ban_div.scrollLeft + state.hover_pos_x + "px"; | |
} | |
}; | |
const handleLeft = () => { | |
const bandiv = document.getElementById("hovs-banner"); | |
bandiv?.scrollBy({ | |
left: -1 * state.scroll_by, | |
}); | |
}; |
This file contains hidden or 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
// **--- Important BEGIN ---** | |
.hovs-hoverComp { | |
display: none; | |
} | |
.hovs-main:hover > .hovs-hoverComp { | |
display: block; | |
position: absolute; | |
} | |
// **--- Important END ---** | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment