hookehuyr

fix 键盘弹出框高度

...@@ -64,16 +64,27 @@ watch( ...@@ -64,16 +64,27 @@ watch(
64 ); 64 );
65 65
66 const openKeyboard = (e) => { 66 const openKeyboard = (e) => {
67 + // // 键盘上移动
68 + // const target_to_view_height = window.innerHeight - e.target.getBoundingClientRect().y; // 元素到适口高度
69 + // const target_top = document.body.scrollHeight - $(e.target).offset().top; // 元素到正文高度
70 + // let scroll_height = "";
71 + // console.warn(target_top);
72 + // if (target_top < 250) {
73 + // document.getElementById("app").style.paddingBottom = "250px";
74 + // window.scrollTo(0, $("#app").height());
75 + // } else {
76 + // // 向上滚动位置
77 + // document.documentElement.scrollTop = (target_top > 250 ? 0 : target_top) + 250;
78 + // }
67 // 键盘上移动 79 // 键盘上移动
68 - const target_to_view_height = window.innerHeight - e.target.getBoundingClientRect().y; // 元素到适口高度 80 + const target_to_view_height =
81 + window.innerHeight - e.target.getBoundingClientRect().bottom; // 元素到适口高度
69 const target_top = document.body.scrollHeight - $(e.target).offset().top; // 元素到正文高度 82 const target_top = document.body.scrollHeight - $(e.target).offset().top; // 元素到正文高度
70 let scroll_height = ""; 83 let scroll_height = "";
71 - if (target_top < 244) { 84 + if (target_to_view_height <= 250) {
72 - document.getElementById("app").style.paddingBottom = "244px"; 85 + document.getElementById("app").style.paddingBottom = "250px";
73 - window.scrollTo(0, $("#app").height());
74 - } else {
75 // 向上滚动位置 86 // 向上滚动位置
76 - document.documentElement.scrollTop = target_top + 244; 87 + document.documentElement.scrollTop = $(e.target).offset().top - 244;
77 } 88 }
78 // 选中添加border颜色 89 // 选中添加border颜色
79 content = $(e.target).parent(); 90 content = $(e.target).parent();
......
...@@ -77,16 +77,21 @@ watch( ...@@ -77,16 +77,21 @@ watch(
77 77
78 const showKeyboard = (e) => { 78 const showKeyboard = (e) => {
79 // 键盘上移动 79 // 键盘上移动
80 - // const target_to_view_height = window.innerHeight - e.target.getBoundingClientRect().y; // 元素到适口高度 80 + const target_to_view_height =
81 + window.innerHeight - e.target.getBoundingClientRect().bottom; // 元素到适口高度
81 const target_top = document.body.scrollHeight - $(e.target).offset().top; // 元素到正文高度 82 const target_top = document.body.scrollHeight - $(e.target).offset().top; // 元素到正文高度
82 let scroll_height = ""; 83 let scroll_height = "";
83 - document.getElementById("app").style.paddingBottom = "244px"; 84 + if (target_to_view_height <= 250) {
84 - if (target_top < 244) { 85 + document.getElementById("app").style.paddingBottom = "250px";
85 - window.scrollTo(0, $("#app").height());
86 - } else {
87 // 向上滚动位置 86 // 向上滚动位置
88 - document.documentElement.scrollTop = target_top + 244; 87 + document.documentElement.scrollTop = $(e.target).offset().top - 244;
89 } 88 }
89 + // if (target_top < 250) {
90 + // window.scrollTo(0, $("#app").height());
91 + // } else {
92 + // // 向上滚动位置
93 + // document.documentElement.scrollTop = (target_top > 500 ? 0 : target_top) + 250;
94 + // }
90 // 选中添加border颜色 95 // 选中添加border颜色
91 content = $(e.target).parent(); 96 content = $(e.target).parent();
92 // TAG: 自定义主题颜色 97 // TAG: 自定义主题颜色
......
...@@ -87,15 +87,14 @@ watch( ...@@ -87,15 +87,14 @@ watch(
87 87
88 const openKeyboard = (e) => { 88 const openKeyboard = (e) => {
89 // 键盘上移动 89 // 键盘上移动
90 - const target_to_view_height = window.innerHeight - e.target.getBoundingClientRect().y; // 元素到适口高度 90 + const target_to_view_height =
91 + window.innerHeight - e.target.getBoundingClientRect().bottom; // 元素到适口高度
91 const target_top = document.body.scrollHeight - $(e.target).offset().top; // 元素到正文高度 92 const target_top = document.body.scrollHeight - $(e.target).offset().top; // 元素到正文高度
92 let scroll_height = ""; 93 let scroll_height = "";
93 - if (target_top < 244) { 94 + if (target_to_view_height <= 250) {
94 - document.getElementById("app").style.paddingBottom = "244px"; 95 + document.getElementById("app").style.paddingBottom = "250px";
95 - window.scrollTo(0, $("#app").height());
96 - } else {
97 // 向上滚动位置 96 // 向上滚动位置
98 - document.documentElement.scrollTop = target_top + 244; 97 + document.documentElement.scrollTop = $(e.target).offset().top - 244;
99 } 98 }
100 // 选中添加border颜色 99 // 选中添加border颜色
101 content = $(e.target).parent(); 100 content = $(e.target).parent();
......