提交 5c22e914 编写于 作者: Q qiang

feat: app-plus onWindowResize

上级 04760838
import {
invoke
} from 'uni-core/service/bridge'
import {
onMethod
} from '../../platform'
const callbacks = []
onMethod('onViewDidResize', res => {
callbacks.forEach(callbackId => {
invoke(callbackId, res)
})
})
export function onWindowResize (callbackId) {
callbacks.push(callbackId)
}
export function offWindowResize (callbackId) {
// 此处和微信平台一致查询不到去掉最后一个
callbacks.splice(callbacks.indexOf(callbackId), 1)
}
......@@ -7,6 +7,10 @@ import {
parseWebviewStyle
} from './parser/webview-style-parser'
import {
publish
} from '../../bridge'
let id = 2
const WEBVIEW_LISTENERS = {
......@@ -57,6 +61,20 @@ export function initWebview (webview, routeOptions) {
})
})
webview.addEventListener('resize', ({
width,
height
}) => {
const res = {
size: {
windowWidth: Math.ceil(width),
windowHeight: Math.ceil(height)
}
}
publish('onViewDidResize', res)
emit('onResize', res, parseInt(webview.id))
})
// TODO 应该结束之前未完成的下拉刷新
on(webview.id + '.startPullDownRefresh', () => {
webview.beginPullToRefresh()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册