Skip to content

Instantly share code, notes, and snippets.

@phpmaps
Created March 17, 2021 21:11
Show Gist options
  • Select an option

  • Save phpmaps/cac4ddf48cba7fbcf48f7352dcd5edbb to your computer and use it in GitHub Desktop.

Select an option

Save phpmaps/cac4ddf48cba7fbcf48f7352dcd5edbb to your computer and use it in GitHub Desktop.
contentEditable
// https://stackoverflow.com/questions/6536166/how-to-find-absolute-or-relative-position-of-last-letter-inside-an-input-field
<div id="textbox">
<span id="edit" contentEditable></span>
<span id="end"></span>
</div>
<div id="report">x:? , y:?</div>
// css
#textbox {
border: solid black 1px;
min-height: 1em;
white-space: nowrap;
}
// javascript
$(function() {
$('#textbox').click(function() {
$('#edit').focus();
});
$('#edit').keypress(function() {
var endoff = $('#end').offset();
$('#report').html('x:' + endoff.left + ' , y:' + endoff.top);
});
});
@phpmaps

phpmaps commented Mar 17, 2021

Copy link
Copy Markdown
Author
    useEffect(() => {
        function listener() {
            setShowCalendar(false);
        }
        document.addEventListener("click", listener);
        return () => {
            document.removeEventListener("click", listener);
        };
    }, []);

@phpmaps

phpmaps commented Mar 17, 2021

Copy link
Copy Markdown
Author
.test {
 pointer-events: none
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment