@@ -16,6 +16,7 @@ export function useStyleEffectSwipeBack({
1616 onSwipeStart,
1717 onSwipeMove,
1818 onSwipeEnd,
19+ onTransitionEnd,
1920} : {
2021 dimRef : React . RefObject < HTMLDivElement > ;
2122 edgeRef : React . RefObject < HTMLDivElement > ;
@@ -28,6 +29,7 @@ export function useStyleEffectSwipeBack({
2829 onSwipeStart ?: ( ) => void ;
2930 onSwipeMove ?: ( args : { dx : number ; ratio : number } ) => void ;
3031 onSwipeEnd ?: ( args : { swiped : boolean } ) => void ;
32+ onTransitionEnd ?: ( args : { swiped : boolean } ) => void ;
3133} ) {
3234 useStyleEffect ( {
3335 styleName : "swipe-back" ,
@@ -101,6 +103,11 @@ export function useStyleEffectSwipeBack({
101103 if ( ref . current . parentElement ?. style . display === "none" ) {
102104 ref . current . parentElement . style . display = "block" ;
103105 }
106+
107+ ref . current . parentElement ?. style . setProperty (
108+ SWIPE_BACK_RATIO_CSS_VAR_NAME ,
109+ String ( ratio ) ,
110+ ) ;
104111 } ) ;
105112
106113 _rAFLock = false ;
@@ -118,8 +125,6 @@ export function useStyleEffectSwipeBack({
118125 $paper . style . transform = `translateX(${ swiped ? "100%" : "0" } )` ;
119126 $paper . style . transition = transitionDuration ;
120127
121- $appBarRef ?. style . removeProperty ( SWIPE_BACK_RATIO_CSS_VAR_NAME ) ;
122-
123128 refs . forEach ( ( ref ) => {
124129 if ( ! ref . current ) {
125130 return ;
@@ -135,7 +140,7 @@ export function useStyleEffectSwipeBack({
135140
136141 resolve ( ) ;
137142
138- listenOnce ( $paper , "transitionend" , ( ) => {
143+ listenOnce ( $paper , [ "transitionend" , "transitioncancel" ] , ( ) => {
139144 const _swiped =
140145 swiped ||
141146 getActivityTransitionState ( ) === "exit-active" ||
@@ -145,6 +150,8 @@ export function useStyleEffectSwipeBack({
145150 $paper . style . overflowY = "" ;
146151 $paper . style . transform = "" ;
147152
153+ $appBarRef ?. style . removeProperty ( SWIPE_BACK_RATIO_CSS_VAR_NAME ) ;
154+
148155 refs . forEach ( ( ref , i ) => {
149156 if ( ! ref . current ) {
150157 return ;
@@ -168,7 +175,13 @@ export function useStyleEffectSwipeBack({
168175 _cachedRef . parentElement . style . display ;
169176 }
170177 }
178+
179+ ref . current . parentElement ?. style . removeProperty (
180+ SWIPE_BACK_RATIO_CSS_VAR_NAME ,
181+ ) ;
171182 } ) ;
183+
184+ onTransitionEnd ?.( { swiped } ) ;
172185 } ) ;
173186 } ) ;
174187 } ) ;
0 commit comments