Parcourir la Source

评论框高度适应

guohh 5 ans auparavant
Parent
commit
7becb7ea37
2 fichiers modifiés avec 17 ajouts et 2 suppressions
  1. 16 0
      2020/x-3/biz/js/common/tool.js
  2. 1 2
      2020/x-3/task-detail.html

+ 16 - 0
2020/x-3/biz/js/common/tool.js

@ -10,7 +10,23 @@ define(["jquery", "ipuUI"], function ($, ipuUI) {
10 10
    return this;
11 11
  };
12 12
13
  // textarea 高度自适应
14
  $.fn.autoHeight = function(){
15
    function autoHeight(elem){
16
      elem.style.height = 'auto';
17
      elem.scrollTop = 0; //防抖动
18
      elem.style.height = elem.scrollHeight + 'px';
19
    }
20
    this.each(function(){
21
      autoHeight(this);
22
      $(this).on('keyup', function(){
23
        autoHeight(this);
24
      });
25
    });
26
  }
27
13 28
  $(function () {
29
    $('textarea[autoHeight]').autoHeight();
14 30
15 31
    // 搜索框交互部分
16 32
    $(".common-search").each(function (i, obj) {

+ 1 - 2
2020/x-3/task-detail.html

@ -103,10 +103,9 @@
103 103
    </div>
104 104
  </div>
105 105
106
107 106
  <div class="ipu-flex-col task-note-input-body">
108 107
    <div class="task-note-input-wrap ipu-fn-bd-t">
109
      <textarea class="task-note-input" placeholder="输入评论内容,@通知其他人"></textarea>
108
      <textarea autoHeight class="task-note-input" placeholder="输入评论内容,@通知其他人" rows="1"></textarea>
110 109
    </div>
111 110
  </div>
112 111
</div>