Skip to content

Instantly share code, notes, and snippets.

View sunnykandev's full-sized avatar
🎯
Focusing

Sunny Kan sunnykandev

🎯
Focusing
  • Berrylium (ygf-riyk-gkm)
  • Canada ⇄ United States
View GitHub Profile
@sunnykandev
sunnykandev / caret.js
Created February 21, 2022 06:03 — forked from nothingismagick/caret.js
Small script to detect caret pixel position in contenteditable div
/**
* Get the caret position in all cases
*
* @returns {object} left, top distance in pixels
*/
getCaretTopPoint () {
const sel = document.getSelection()
const r = sel.getRangeAt(0)
let rect
let r2
@sunnykandev
sunnykandev / caret.js
Created February 21, 2022 06:03 — forked from nothingismagick/caret.js
Small script to detect caret pixel position in contenteditable div
/**
* Get the caret position in all cases
*
* @returns {object} left, top distance in pixels
*/
getCaretTopPoint () {
const sel = document.getSelection()
const r = sel.getRangeAt(0)
let rect
let r2
@sunnykandev
sunnykandev / caret.js
Created February 21, 2022 06:03 — forked from nothingismagick/caret.js
Small script to detect caret pixel position in contenteditable div
/**
* Get the caret position in all cases
*
* @returns {object} left, top distance in pixels
*/
getCaretTopPoint () {
const sel = document.getSelection()
const r = sel.getRangeAt(0)
let rect
let r2