提交 956f95ab 编写于 作者: fxy060608's avatar fxy060608

fix(h5): onPageScroll,onReachBottom

上级 4f32a0f2
......@@ -9,8 +9,12 @@ export function isPage (vm) {
return false
}
export function normalizeDataset (dataset = {}) {
// ios8.x,9.x Object.assign({},dataset) 始终返回 {}
export function hasLifecycleHook (vueOptions = {}, hook) {
return Array.isArray(vueOptions[hook]) && vueOptions[hook].length
}
export function normalizeDataset (dataset = {}) {
// ios8.x,9.x Object.assign({},dataset) 始终返回 {}
// http://ask.dcloud.net.cn/question/70246
const result = JSON.parse(JSON.stringify(dataset))
if (__PLATFORM__ === 'h5') {
......
import {
isFn,
isPlainObject,
supportsPassive
} from 'uni-shared'
import {
hasLifecycleHook
} from 'uni-helpers/index'
import {
NAVBAR_HEIGHT,
TABBAR_HEIGHT
......@@ -17,7 +20,10 @@ import {
import requestComponentInfo from './request-component-info'
import { requestComponentObserver, destroyComponentObserver } from './request-component-observer'
import {
requestComponentObserver,
destroyComponentObserver
} from './request-component-observer'
const passiveOptions = supportsPassive ? {
passive: false
......@@ -26,7 +32,8 @@ const passiveOptions = supportsPassive ? {
function updateCssVar (vm) {
if (uni.canIUse('css.var')) {
const pageVm = vm.$parent.$parent
const windowTop = pageVm.showNavigationBar && pageVm.navigationBar.type !== 'transparent' ? (NAVBAR_HEIGHT + 'px')
const windowTop = pageVm.showNavigationBar && pageVm.navigationBar.type !== 'transparent' ? (NAVBAR_HEIGHT +
'px')
: '0px'
const windowBottom = getApp().$children[0].showTabBar ? (TABBAR_HEIGHT + 'px') : '0px'
const style = document.documentElement.style
......@@ -69,11 +76,12 @@ export default function initSubscribe (subscribe) {
document.addEventListener('touchmove', disableScrollListener, passiveOptions)
}
const enablePageScroll = isFn(vm.$options.onPageScroll)
const enablePageReachBottom = isFn(vm.$options.onReachBottom)
const enablePageScroll = hasLifecycleHook(vm.$options, 'onPageScroll')
const enablePageReachBottom = hasLifecycleHook(vm.$options, 'onReachBottom')
const onReachBottomDistance = pageVm.onReachBottomDistance
const enableTransparentTitleNView = isPlainObject(pageVm.titleNView) && pageVm.titleNView.type === 'transparent'
const enableTransparentTitleNView = isPlainObject(pageVm.titleNView) && pageVm.titleNView.type ===
'transparent'
if (scrollListener) {
document.removeEventListener('scroll', scrollListener)
......@@ -92,4 +100,4 @@ export default function initSubscribe (subscribe) {
}
})
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册