提交 6c6903d3 编写于 作者: Q qiang

fix: 解决 iOS13 部分组件触摸交互时UI失去响应的问题 question/98881

上级 54cb9604
...@@ -3,6 +3,7 @@ import { ...@@ -3,6 +3,7 @@ import {
deepClone deepClone
} from 'uni-shared' } from 'uni-shared'
import { import {
initScrollBounce,
disableScrollBounce disableScrollBounce
} from 'uni-platform/helpers/scroll' } from 'uni-platform/helpers/scroll'
...@@ -34,6 +35,7 @@ export default { ...@@ -34,6 +35,7 @@ export default {
}, },
mounted: function () { mounted: function () {
this._resize() this._resize()
initScrollBounce()
}, },
methods: { methods: {
_resize () { _resize () {
......
...@@ -12,6 +12,7 @@ import { ...@@ -12,6 +12,7 @@ import {
STD STD
} from './utils' } from './utils'
import { import {
initScrollBounce,
disableScrollBounce disableScrollBounce
} from 'uni-platform/helpers/scroll' } from 'uni-platform/helpers/scroll'
var requesting = false var requesting = false
...@@ -227,6 +228,7 @@ export default { ...@@ -227,6 +228,7 @@ export default {
this._friction.reconfigure(1, this.frictionNumber) this._friction.reconfigure(1, this.frictionNumber)
this._STD.reconfigure(1, 9 * Math.pow(this.dampingNumber, 2) / 40, this.dampingNumber) this._STD.reconfigure(1, 9 * Math.pow(this.dampingNumber, 2) / 40, this.dampingNumber)
this.$el.style.transformOrigin = 'center' this.$el.style.transformOrigin = 'center'
initScrollBounce()
}, },
methods: { methods: {
_getPx (val) { _getPx (val) {
......
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
Spring Spring
} from 'uni-mixins/scroller/Spring' } from 'uni-mixins/scroller/Spring'
import { import {
initScrollBounce,
disableScrollBounce disableScrollBounce
} from 'uni-platform/helpers/scroll' } from 'uni-platform/helpers/scroll'
...@@ -93,6 +94,7 @@ export default { ...@@ -93,6 +94,7 @@ export default {
this.update() this.update()
}) })
initClick(this.$el) initClick(this.$el)
initScrollBounce()
}, },
methods: { methods: {
_setItemHeight (height) { _setItemHeight (height) {
......
...@@ -74,6 +74,7 @@ import { ...@@ -74,6 +74,7 @@ import {
supportsPassive supportsPassive
} from 'uni-shared' } from 'uni-shared'
import { import {
initScrollBounce,
disableScrollBounce disableScrollBounce
} from 'uni-platform/helpers/scroll' } from 'uni-platform/helpers/scroll'
...@@ -294,6 +295,7 @@ export default { ...@@ -294,6 +295,7 @@ export default {
passive: false passive: false
} : false) } : false)
this.$refs.main.addEventListener('touchend', this.__handleTouchEnd, passiveOptions) this.$refs.main.addEventListener('touchend', this.__handleTouchEnd, passiveOptions)
initScrollBounce()
}, },
activated () { activated () {
// 还原 scroll-view 滚动位置 // 还原 scroll-view 滚动位置
......
...@@ -2,40 +2,26 @@ import { ...@@ -2,40 +2,26 @@ import {
plusReady plusReady
} from 'uni-shared' } from 'uni-shared'
let view let webview
let pullToRefreshStyle let pullToRefreshStyle
let disabled
const lastAction = {} export function initScrollBounce () {
plusReady(() => {
if (!webview) {
webview = plus.webview.currentWebview()
}
if (!pullToRefreshStyle) {
pullToRefreshStyle = (webview.getStyle() || {}).pullToRefresh || {}
}
})
}
export function disableScrollBounce ({ export function disableScrollBounce ({
disable disable
}) { }) {
function exec () { if (pullToRefreshStyle && pullToRefreshStyle.support) {
if (!view) { webview.setPullToRefresh(Object.assign({}, pullToRefreshStyle, {
view = plus.webview.currentWebview() support: !disable
} }))
if (!disabled) {
pullToRefreshStyle = (view.getStyle() || {}).pullToRefresh || {}
}
disabled = disable
if (pullToRefreshStyle.support) {
view.setPullToRefresh(Object.assign({}, pullToRefreshStyle, {
support: !disable
}))
}
}
const time = Date.now()
if (disable === lastAction.disable && time - lastAction.time < 20) {
return
} }
lastAction.disable = disable
lastAction.time = time
plusReady(() => {
if (plus.os.name === 'iOS') {
// 延迟执行避免iOS13触摸卡死
setTimeout(exec, 20)
} else {
exec()
}
})
} }
export function initScrollBounce () {
}
export function disableScrollBounce ({ export function disableScrollBounce ({
disable disable
}) { }) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册