mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
refactor(ios): disable navigation gesture with js (#9287)
Do not toggle navigation gesture native to avoid unexpected behavior. close AF-1958, AF-1797
This commit is contained in:
@@ -49,7 +49,7 @@ import { ModalConfigProvider } from './modal-config';
|
||||
import { Cookie } from './plugins/cookie';
|
||||
import { Hashcash } from './plugins/hashcash';
|
||||
import { Intelligents } from './plugins/intelligents';
|
||||
import { NavigationGesture } from './plugins/navigation-gesture';
|
||||
import { enableNavigationGesture$ } from './web-navigation-control';
|
||||
|
||||
const future = {
|
||||
v7_startTransition: true,
|
||||
@@ -107,9 +107,9 @@ framework.impl(VirtualKeyboardProvider, {
|
||||
},
|
||||
});
|
||||
framework.impl(NavigationGestureProvider, {
|
||||
isEnabled: () => NavigationGesture.isEnabled(),
|
||||
enable: () => NavigationGesture.enable(),
|
||||
disable: () => NavigationGesture.disable(),
|
||||
isEnabled: () => enableNavigationGesture$.value,
|
||||
enable: () => enableNavigationGesture$.next(true),
|
||||
disable: () => enableNavigationGesture$.next(false),
|
||||
});
|
||||
framework.impl(HapticProvider, {
|
||||
impact: options => Haptics.impact(options as any),
|
||||
|
||||
13
packages/frontend/apps/ios/src/web-navigation-control.tsx
Normal file
13
packages/frontend/apps/ios/src/web-navigation-control.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { LiveData } from '@toeverything/infra';
|
||||
|
||||
export const enableNavigationGesture$ = new LiveData(false);
|
||||
|
||||
const onTouchStart = (e: TouchEvent) => {
|
||||
if (enableNavigationGesture$.value) return;
|
||||
|
||||
const clientX = e.changedTouches[0].clientX;
|
||||
if (clientX <= 25) {
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
document.body.addEventListener('touchstart', onTouchStart, { passive: false });
|
||||
Reference in New Issue
Block a user