Created
November 18, 2017 17:27
-
-
Save rahilwazir/b591090aa31e25b180f8b1f79fb41e16 to your computer and use it in GitHub Desktop.
Focused Line for readers
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
(() => { | |
'use strict'; | |
const height = 20; | |
const body = document.querySelector('body'); | |
const focusedLine = document.createElement('div'); | |
focusedLine.setAttribute('id', 'focused-line'); | |
body.appendChild(focusedLine); | |
focusedLine.style.cssText = `position: absolute; width: 100%; background-color: rgba(230, 228, 63, 0.5); height: ${height}px; z-index: -1; display: none;`; | |
document.addEventListener('click', changePosition); | |
function changePosition(e) { | |
let y = e.clientY; | |
y -= parseInt(height) / 2; | |
focusedLine.style.display = ''; | |
focusedLine.style.top = `${y}px`; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment