Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
package.dist.util.Caret.js.map Maven / Gradle / Ivy
{"version":3,"file":"Caret.js","sourceRoot":"","sources":["../../src/util/Caret.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAC,KAAuB,EAAiB,EAAE;IACnE,aAAa;IACb,IAAI,QAAQ,GAAkB,CAAC,CAAC;IAEhC,IAAI,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC,cAAc,KAAK,CAAC,EAAE,EAAE,kBAAkB;QAC3E,QAAQ,GAAG,KAAK,CAAC,kBAAkB,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC;KAC/F;IAED,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,KAAuB,EAAE,QAAuB,EAAE,EAAE;IAC7E,IAAI,KAAK,CAAC,cAAc,EAAE;QACzB,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,KAAK,CAAC,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;KAC5C;SAAM;QACN,KAAK,CAAC,KAAK,EAAE,CAAC;KACd;AACF,CAAC,CAAC;AAEF,OAAO,EACN,gBAAgB,EAChB,gBAAgB,GAChB,CAAC","sourcesContent":["/**\n * Returns the caret (cursor) position of the specified text field (field).\n * Return value range is 0-field.value.length.\n */\nconst getCaretPosition = (field: HTMLInputElement): number | null => {\n\t// Initialize\n\tlet caretPos: number | null = 0;\n\n\tif (field.selectionStart || field.selectionStart === 0) { // Firefox support\n\t\tcaretPos = field.selectionDirection === \"backward\" ? field.selectionStart : field.selectionEnd;\n\t}\n\n\treturn caretPos;\n};\n\nconst setCaretPosition = (field: HTMLInputElement, caretPos: number | null) => {\n\tif (field.selectionStart) {\n\t\tfield.focus();\n\t\tfield.setSelectionRange(caretPos, caretPos);\n\t} else {\n\t\tfield.focus();\n\t}\n};\n\nexport {\n\tgetCaretPosition,\n\tsetCaretPosition,\n};\n"]}