Move /platform/detection vars into /env (#9707)
* Add platform vars to env * Replace /platform/detection with /env
This commit is contained in:
@@ -9,9 +9,9 @@ import {
|
||||
import EventEmitter from 'eventemitter3'
|
||||
|
||||
import {ScrollProvider} from '#/lib/ScrollContext'
|
||||
import {isNative, isWeb} from '#/platform/detection'
|
||||
import {useMinimalShellMode} from '#/state/shell'
|
||||
import {useShellLayout} from '#/state/shell/shell-layout'
|
||||
import {IS_NATIVE, IS_WEB} from '#/env'
|
||||
|
||||
const WEB_HIDE_SHELL_THRESHOLD = 200
|
||||
|
||||
@@ -35,7 +35,7 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (isWeb) {
|
||||
if (IS_WEB) {
|
||||
return listenToForcedWindowScroll(() => {
|
||||
startDragOffset.set(null)
|
||||
startMode.set(null)
|
||||
@@ -48,7 +48,7 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
|
||||
(e: NativeScrollEvent) => {
|
||||
'worklet'
|
||||
const offsetY = Math.max(0, e.contentOffset.y)
|
||||
if (isNative) {
|
||||
if (IS_NATIVE) {
|
||||
const startDragOffsetValue = startDragOffset.get()
|
||||
if (startDragOffsetValue === null) {
|
||||
return
|
||||
@@ -75,7 +75,7 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
|
||||
(e: NativeScrollEvent) => {
|
||||
'worklet'
|
||||
const offsetY = Math.max(0, e.contentOffset.y)
|
||||
if (isNative) {
|
||||
if (IS_NATIVE) {
|
||||
startDragOffset.set(offsetY)
|
||||
startMode.set(headerMode.get())
|
||||
}
|
||||
@@ -86,7 +86,7 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
|
||||
const onEndDrag = useCallback(
|
||||
(e: NativeScrollEvent) => {
|
||||
'worklet'
|
||||
if (isNative) {
|
||||
if (IS_NATIVE) {
|
||||
if (e.velocity && e.velocity.y !== 0) {
|
||||
// If we detect a velocity, wait for onMomentumEnd to snap.
|
||||
return
|
||||
@@ -100,7 +100,7 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
|
||||
const onMomentumEnd = useCallback(
|
||||
(e: NativeScrollEvent) => {
|
||||
'worklet'
|
||||
if (isNative) {
|
||||
if (IS_NATIVE) {
|
||||
snapToClosestState(e)
|
||||
}
|
||||
},
|
||||
@@ -111,7 +111,7 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
|
||||
(e: NativeScrollEvent) => {
|
||||
'worklet'
|
||||
const offsetY = Math.max(0, e.contentOffset.y)
|
||||
if (isNative) {
|
||||
if (IS_NATIVE) {
|
||||
const startDragOffsetValue = startDragOffset.get()
|
||||
const startModeValue = startMode.get()
|
||||
if (startDragOffsetValue === null || startModeValue === null) {
|
||||
@@ -177,7 +177,7 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
|
||||
|
||||
const emitter = new EventEmitter()
|
||||
|
||||
if (isWeb) {
|
||||
if (IS_WEB) {
|
||||
const originalScroll = window.scroll
|
||||
window.scroll = function () {
|
||||
emitter.emit('forced-scroll')
|
||||
|
||||
Reference in New Issue
Block a user