File tree Expand file tree Collapse file tree 6 files changed +40
-11
lines changed
Expand file tree Collapse file tree 6 files changed +40
-11
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @stackflow/plugin-basic-ui " : patch
3+ " @stackflow/react-ui-core " : patch
4+ ---
5+
6+ fix(plugin-basic-ui,react-ui-core): prevent touch events while transitioning
Original file line number Diff line number Diff line change @@ -115,14 +115,5 @@ export const stackWrapper = recipe({
115115 android,
116116 cupertino,
117117 } ,
118- globalTransitionState : {
119- idle : { } ,
120- loading : {
121- pointerEvents : "none" ,
122- } ,
123- paused : {
124- pointerEvents : "none" ,
125- } ,
126- } ,
127118 } ,
128119} ) ;
Original file line number Diff line number Diff line change @@ -61,7 +61,6 @@ export const basicUIPlugin: (
6161 className = { compact ( [
6262 css . stackWrapper ( {
6363 theme : initialContext ?. theme ?? _options . theme ,
64- globalTransitionState : stack . globalTransitionState ,
6564 } ) ,
6665 _options . rootClassName ,
6766 ] ) . join ( " " ) }
Original file line number Diff line number Diff line change 1- import { useActions } from "@stackflow/react" ;
1+ import { useActions , useStack } from "@stackflow/react" ;
22import {
33 useActivityDataAttributes ,
44 useLazy ,
55 useMounted ,
66 useNullableActivity ,
7+ usePreventTouchDuringTransition ,
78 useStyleEffectHide ,
89 useStyleEffectOffset ,
910 useStyleEffectSwipeBack ,
@@ -194,6 +195,10 @@ const AppScreen: React.FC<AppScreenProps> = ({
194195 }
195196 } ;
196197
198+ usePreventTouchDuringTransition ( {
199+ appScreenRef,
200+ } ) ;
201+
197202 return (
198203 < Context . Provider
199204 value = { useMemo (
Original file line number Diff line number Diff line change @@ -8,3 +8,4 @@ export * from "./useStyleEffectOffset";
88export * from "./useStyleEffectSwipeBack" ;
99export * from "./useZIndexBase" ;
1010export * from "./useActivityDataAttributes" ;
11+ export * from "./usePreventTouchDuringTransition" ;
Original file line number Diff line number Diff line change 1+ import { useStack } from "@stackflow/react" ;
2+ import { useEffect } from "react" ;
3+
4+ export function usePreventTouchDuringTransition ( {
5+ appScreenRef,
6+ } : {
7+ appScreenRef : React . RefObject < HTMLDivElement > ;
8+ } ) {
9+ const { globalTransitionState } = useStack ( ) ;
10+
11+ useEffect ( ( ) => {
12+ const $appScreen = appScreenRef . current ;
13+ if ( ! $appScreen || globalTransitionState === "idle" ) {
14+ return ;
15+ }
16+
17+ const onTouchStart = ( e : TouchEvent ) => {
18+ e . preventDefault ( ) ;
19+ } ;
20+
21+ $appScreen . addEventListener ( "touchstart" , onTouchStart ) ;
22+
23+ return ( ) => {
24+ $appScreen . removeEventListener ( "touchstart" , onTouchStart ) ;
25+ } ;
26+ } , [ globalTransitionState ] ) ;
27+ }
You can’t perform that action at this time.
0 commit comments