-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
路由切换使用native-stack&相交api部分问题修复 #1815
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ import { isArray, isObject, isString, noop } from '@mpxjs/utils' | |
import throttle from 'lodash/throttle' | ||
import { Dimensions } from 'react-native' | ||
import { getFocusedNavigation } from '../../../common/js' | ||
|
||
const WindowRefStr = 'window' | ||
const IgnoreTarget = 'ignore' | ||
const DefaultMargin = { top: 0, bottom: 0, left: 0, right: 0 } | ||
|
@@ -12,10 +11,14 @@ class RNIntersectionObserver { | |
constructor (component, options, intersectionCtx) { | ||
this.id = idCount++ | ||
this.component = component | ||
this.options = options | ||
this.thresholds = options.thresholds.sort((a, b) => a - b) || [0] | ||
this.initialRatio = options.initialRatio || 0 | ||
this.observeAll = options.observeAll || false | ||
this.options = Object.assign({ | ||
thresholds: [0], | ||
initialRatio: 0, | ||
observeAll: false | ||
}, options || {}) | ||
this.thresholds = this.options.thresholds.sort((a, b) => a - b) || [0] | ||
this.initialRatio = this.options.initialRatio | ||
this.observeAll = this.options.observeAll | ||
|
||
// 组件上挂载对应的observers,用于在组件销毁的时候进行批量disconnect | ||
this.component._intersectionObservers = this.component.__intersectionObservers || [] | ||
|
@@ -26,7 +29,7 @@ class RNIntersectionObserver { | |
this.margins = DefaultMargin | ||
this.callback = noop | ||
|
||
this.throttleMeasure = this.getThrottleMeasure(options.throttleTime || 100) | ||
this.throttleMeasure = this.getThrottleMeasure(this.options.throttleTime || 100) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 默认值直接写在上面呗 |
||
|
||
// 记录上一次相交的比例 | ||
this.previousIntersectionRatio = [] | ||
|
@@ -65,7 +68,7 @@ class RNIntersectionObserver { | |
|
||
observe (selector, callback) { | ||
if (this.observerRefs) { | ||
console.error('"observe" call can be only called once in IntersectionObserver') | ||
console.warn('"observe" call can be only called once in IntersectionObserver') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 走utils中的logger There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 把component传进去,可以有更多定位信息 |
||
return | ||
} | ||
let targetRef = null | ||
|
@@ -75,7 +78,7 @@ class RNIntersectionObserver { | |
targetRef = this.component.__selectRef(selector, 'node') | ||
} | ||
if (!targetRef || targetRef.length === 0) { | ||
console.error('intersection observer target not found') | ||
console.warn('intersection observer target not found') | ||
return | ||
} | ||
this.observerRefs = isArray(targetRef) ? targetRef : [targetRef] | ||
|
@@ -95,10 +98,10 @@ class RNIntersectionObserver { | |
} | ||
|
||
const windowRect = { | ||
top: navigationLayout.y + this.margins.top, | ||
left: this.margins.left, | ||
right: navigationLayout.width - this.margins.right, | ||
bottom: navigationLayout.y + navigationLayout.height - this.margins.bottom | ||
top: navigationLayout.y - this.margins.top, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 为啥是这么改 |
||
left: 0 - this.margins.left, | ||
right: navigationLayout.width + this.margins.right, | ||
bottom: navigationLayout.y + navigationLayout.height + this.margins.bottom | ||
} | ||
|
||
this.windowRect = windowRect | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -505,14 +505,9 @@ export function getDefaultOptions ({ type, rawOptions = {}, currentInject }) { | |
headerStyle: { | ||
backgroundColor: pageConfig.navigationBarBackgroundColor || '#000000' | ||
}, | ||
headerTintColor: pageConfig.navigationBarTextStyle || 'white' | ||
headerTintColor: pageConfig.navigationBarTextStyle || 'white', | ||
statusBarTranslucent: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 安卓statusbar那堆东西确定不要了? |
||
}) | ||
if (__mpx_mode__ === 'android') { | ||
ReactNative.StatusBar.setBarStyle(pageConfig.barStyle || 'dark-content') | ||
ReactNative.StatusBar.setTranslucent(isCustom) // 控制statusbar是否占位 | ||
const color = isCustom ? 'transparent' : pageConfig.statusBarColor | ||
color && ReactNative.StatusBar.setBackgroundColor(color) | ||
} | ||
}, []) | ||
|
||
const rootRef = useRef(null) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|| [0]不需要了