Commit 7a1967c5 authored by 24776's avatar 24776

android键盘

parent 6d21b97c
......@@ -39,7 +39,7 @@ export default {
lastClickTime: 0,
startY: 0, // 触摸位置
endY: 0, // 结束位置
distance: 0, //android应该滚动距离
distance: 0, // android应该滚动距离
docmHeight: 0, // 默认屏幕高度
showHeight: 0, // 实时屏幕高度
topHeight: 0, // content距离顶部的高度
......@@ -112,22 +112,22 @@ export default {
}
},
touchEnd (event) {
if(detectOS() === 'ios'){
if ((event.timeStamp - this.lastClickTime) < this.tapDelay) return
this.lastClickTime = event.timeStamp
if (event.target.nodeName === 'INPUT' || event.target.nodeName === 'TEXTAREA') {
this.endY = event.changedTouches[0].clientY
if ((this.endY - this.startY > 100) || this.endY - this.startY < -100) return
let keyboardHeight = this.getKeyBoardHeight()
let scrollTop = (this.winHeight - this.endY) < keyboardHeight ? (keyboardHeight - (this.winHeight - this.endY)) : 0
if (scrollTop) {
this.$el.style.transition = 'all .2s cubic-bezier(0.165, 0.84, 0.44, 1) 0s'
this.$el.style.transform = 'translate(0px, -' + scrollTop + 'px) scale(1) translateZ(0px)'
this.$el.style.paddingBottom = (scrollTop + 20) + 'px'
this.$el.style.height = parseInt(this.height) + scrollTop + 'px'
if (detectOS() === 'ios') {
if ((event.timeStamp - this.lastClickTime) < this.tapDelay) return
this.lastClickTime = event.timeStamp
if (event.target.nodeName === 'INPUT' || event.target.nodeName === 'TEXTAREA') {
this.endY = event.changedTouches[0].clientY
if ((this.endY - this.startY > 100) || this.endY - this.startY < -100) return
let keyboardHeight = this.getKeyBoardHeight()
let scrollTop = (this.winHeight - this.endY) < keyboardHeight ? (keyboardHeight - (this.winHeight - this.endY)) : 0
if (scrollTop) {
this.$el.style.transition = 'all .2s cubic-bezier(0.165, 0.84, 0.44, 1) 0s'
this.$el.style.transform = 'translate(0px, -' + scrollTop + 'px) scale(1) translateZ(0px)'
this.$el.style.paddingBottom = (scrollTop + 20) + 'px'
this.$el.style.height = parseInt(this.height) + scrollTop + 'px'
}
event.target.focus()
}
event.target.focus()
}
}
},
getHeaderHeight () {
......
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