Commit 5c209d10 authored by liujiaxin's avatar liujiaxin

feat: custom formula input

parent 9744c8f3
...@@ -68,8 +68,19 @@ export class FormulaInputComponent implements OnInit, OnChanges, OnDestroy, Afte ...@@ -68,8 +68,19 @@ export class FormulaInputComponent implements OnInit, OnChanges, OnDestroy, Afte
const rect = this.inputEl.nativeElement.getBoundingClientRect(); const rect = this.inputEl.nativeElement.getBoundingClientRect();
const fb = document.getElementById(this.FB_id); const fb = document.getElementById(this.FB_id);
fb.style.position = 'absolute'; fb.style.position = 'absolute';
fb.style.left = rect.left + rect.width + 'px'; let left = rect.left + rect.width;
fb.style.top = rect.top + 'px'; let top = rect.top;
// @ts-ignore
const padWidth = $('#' + this.FB_id).outerWidth() * .8;
// @ts-ignore
const ww = $(window).innerWidth();
if ((left + padWidth) > ww) {
left = ww - padWidth;
top = top + rect.height;
}
console.log('left', left);
fb.style.left = left + 'px';
fb.style.top = top + 'px';
fb.style.visibility = 'visible'; fb.style.visibility = 'visible';
} }
updateValue(val) { updateValue(val) {
......
<div class="model-content"> <div class="model-content">
<app-formula-input [(ngfModel)]="item.title" (ngfBlur)="save()"></app-formula-input><br> <app-formula-input style="position: absolute;right:0;" [(ngfModel)]="item.title" (ngfBlur)="save()"></app-formula-input><br>
<app-formula-input [(ngfModel)]="item.title" (ngfBlur)="save()"></app-formula-input><br> <app-formula-input [(ngfModel)]="item.title" (ngfBlur)="save()"></app-formula-input><br>
<div style="padding: 20px;"> <div style="padding: 20px;">
...@@ -182,8 +182,8 @@ ...@@ -182,8 +182,8 @@
</div> </div>
</div> </div>
<div *ngFor="let op of item.choice_obj.optionArr" style="border: 1px solid #ccc; margin: 10px; padding: 10px; border-radius: 5px;"> <div *ngFor="let op of item.choice_obj.optionArr" style="border: 1px solid #ccc; margin: 10px; padding: 10px; border-radius: 5px;">
<div style="margin-top: 20px; display: flex; align-items: center; width: 500px;"> <div style="margin-top: 20px; display: flex; align-items: center; width: 500px;">
<span style="margin-right: 5px;">{{op.id}}:</span> <span style="margin-right: 5px;">{{op.id}}:</span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment