You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
619 B
26 lines
619 B
|
3 years ago
|
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) {
|
||
|
|
// TODO 目前 on 和 off 即使传入同一个 function,获取到的 callbackId 也不会一致,导致不能 off 掉指定
|
||
|
|
// 后续修复
|
||
|
|
// 此处和微信平台一致查询不到去掉最后一个
|
||
|
|
callbacks.splice(callbacks.indexOf(callbackId), 1)
|
||
|
|
}
|