Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cb9b981

Browse filesBrowse files
committed
Completed lesson 22
Gots all kinds of client wreckts
1 parent b80fe3c commit cb9b981
Copy full SHA for cb9b981

File tree

Expand file treeCollapse file tree

1 file changed

+21
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+21
-1
lines changed
Open diff view settings
Collapse file

‎22 - Follow Along Link Highlighter/index-START.html‎

Copy file name to clipboardExpand all lines: 22 - Follow Along Link Highlighter/index-START.html
+21-1Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,27 @@
2727

2828
<script>
2929
// 👀👀👀👀👀👀👀👀👀👀👀👀👀👀👀
30+
const triggers = document.querySelectorAll('a');
31+
const highlight = document.createElement('span');
32+
highlight.classList.add('highlight');
33+
document.body.append(highlight);
34+
35+
function highlightLink() {
36+
const linkCoords = this.getBoundingClientRect();
37+
38+
const coords = {
39+
width: linkCoords.width,
40+
height: linkCoords.height,
41+
top: linkCoords.top + window.scrollY,
42+
left: linkCoords.left + window.scrollX
43+
}
44+
highlight.style.width = `${coords.width}px`;
45+
highlight.style.height = `${coords.height}px`;
46+
highlight.style.transform = `translate(${coords.left}px,${coords.top}px)`;
47+
}
48+
triggers.forEach((element) => {
49+
element.addEventListener('mouseenter', highlightLink);
50+
})
3051
</script>
3152
</body>
3253
</html>
33-

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.