Created
December 2, 2015 02:29
-
-
Save PaulBGD/fe5139dc16a791a34d14 to your computer and use it in GitHub Desktop.
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
updateSelector() { | |
if (this.running) { | |
return this.selector.style.display = 'none'; | |
} | |
let lines = this.lines; | |
let length = this.input.value.length; | |
if (!this.running) { | |
length += this.prefix.length; | |
} | |
length -= this.input.value.length - this.input.selectionStart; | |
let moved = (length * 9) - window.innerWidth; | |
if (moved > 0) { // we're wrapping the line | |
lines += Math.ceil(moved / window.innerWidth); | |
moved = moved % window.innerWidth; | |
moved = moved / 9; // how many spaces | |
length = Math.ceil(moved); | |
} | |
this.selector.style.left = (9 * length) + 'px'; | |
this.selector.style.top = ((20 * lines) + 5 - window.scrollY) + 'px'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment