瀏覽代碼

输入框定位问题

luolei 5 年之前
父節點
當前提交
7da35f692a
共有 5 個文件被更改,包括 17 次插入12 次删除
  1. 0 1
      src/common/Input.vue
  2. 1 1
      src/components/DetailBox.vue
  3. 0 4
      src/components/DiagTreat.vue
  4. 4 5
      src/components/Login.vue
  5. 12 1
      src/utils/tools.js

+ 0 - 1
src/common/Input.vue

@@ -45,7 +45,6 @@
         // this.$emit("updata",newData);
       },
       focus(e){
-        this.$emit('focusPosition',e)
         if(isIos()){
           // $(".btscroll").css({'position':'absolute'})
           $(".foot").css({'display':'none'})

+ 1 - 1
src/components/DetailBox.vue

@@ -173,7 +173,7 @@
   .detailBox-wrap{
     width: 100%;
     // overflow-y: auto;
-    position: fixed;
+    position: absolute;
     // bottom: 0; //iPhone6plus键盘收起会跳转
     top:45px;
     bottom: 0;

+ 0 - 4
src/components/DiagTreat.vue

@@ -21,7 +21,6 @@
         <Input v-if="it.controlType==6 || it.controlType==7"
             :item="it"
             :key="it.id"
-            @focusPosition="focusPosition"
             @updata="updataData($event,it.id,i)"/>
         <!-- 文本域 -->
         <ComTextArea v-if="it.controlType == 5"
@@ -100,9 +99,6 @@
       })
     },
     methods:{
-      focusPosition(e){
-        // this.scroll.scrollToElement(e.target,100,0,-40);
-      },
       onScroll(data) {
         this.$store.commit('setScroll', data);
         document.activeElement.scrollIntoViewIfNeeded(true);

+ 4 - 5
src/components/Login.vue

@@ -101,12 +101,11 @@ export default {
       this.show = !show;
     },
     blur() {
-      // document.activeElement.scrollIntoViewIfNeeded(true);      
-      // setTimeout(() => {
-      //   document.activeElement.scrollIntoViewIfNeeded(true);
-      // }, 300);
       if(MobileDevice.getModels().join(' or ').indexOf('6') == -1){
-        window.scroll(0,0)
+        document.activeElement.scrollIntoViewIfNeeded(true);      
+        setTimeout(() => {
+          document.activeElement.scrollIntoViewIfNeeded(true);
+        }, 300);
       }
     },
     changeName() {

+ 12 - 1
src/utils/tools.js

@@ -319,7 +319,18 @@ function setScroll(scroll,flg,wrapper){
       scrollY: flg,
       click: true,
       probeType:3,
-      bounceTime:500
+      // bounceTime:800,
+      momentumLimitTime:300,//只有在屏幕上快速滑动的时间小于 momentumLimitTime,才能开启 momentum 动画。
+      momentumLimitDistance:15,//只有在屏幕上快速滑动的距离大于 momentumLimitDistance,才能开启 momentum 动画。
+      swipeTime:500,//设置 momentum 动画的动画时长
+      deceleration:0.015,
+      swipeBounceTime:500,
+      bounce: {
+        top: false,
+        bottom: false,
+        left: false,
+        right: false
+      }
   })
 }