✌️
This commit is contained in:
parent
83fde7c131
commit
3e91159bc3
5 changed files with 43 additions and 29 deletions
|
|
@ -82,6 +82,15 @@ class Autocomplete {
|
|||
// 既に開いているサジェストは閉じる
|
||||
this.close();
|
||||
|
||||
//#region サジェストを表示すべき位置を計算
|
||||
const caretPosition = getCaretCoordinates(this.textarea, this.textarea.selectionStart);
|
||||
|
||||
const rect = this.textarea.getBoundingClientRect();
|
||||
|
||||
const x = rect.left + caretPosition.left - this.textarea.scrollLeft;
|
||||
const y = rect.top + caretPosition.top - this.textarea.scrollTop;
|
||||
//#endregion
|
||||
|
||||
// サジェスト要素作成
|
||||
this.suggestion = new MkAutocomplete({
|
||||
propsData: {
|
||||
|
|
@ -89,22 +98,12 @@ class Autocomplete {
|
|||
complete: this.complete,
|
||||
close: this.close,
|
||||
type: type,
|
||||
q: q
|
||||
q: q,
|
||||
x,
|
||||
y
|
||||
}
|
||||
}).$mount();
|
||||
|
||||
//#region サジェストを表示すべき位置を計算
|
||||
const caretPosition = getCaretCoordinates(this.textarea, this.textarea.selectionStart);
|
||||
|
||||
const rect = this.textarea.getBoundingClientRect();
|
||||
|
||||
const x = rect.left + window.pageXOffset + caretPosition.left - this.textarea.scrollLeft;
|
||||
const y = rect.top + window.pageYOffset + caretPosition.top - this.textarea.scrollTop;
|
||||
//#endregion
|
||||
|
||||
this.suggestion.$el.style.left = x + 'px';
|
||||
this.suggestion.$el.style.top = y + 'px';
|
||||
|
||||
// 要素追加
|
||||
document.body.appendChild(this.suggestion.$el);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue