File tree 3 files changed +20
-8
lines changed
3 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,10 @@ export const useAnimation = (
75
75
const getAnimation = ( ) => cache ?. [ 0 ] ;
76
76
const handle = createHandle ( ) ;
77
77
78
+ const cancel = ( ) => {
79
+ handle . _cancel ( getAnimation ( ) ) ;
80
+ } ;
81
+
78
82
const externalHandle : AnimationHandle = {
79
83
play : ( opts ) => {
80
84
handle . _play ( initAnimation ( getKeyframes ( ) , getOptions ( ) ) , opts ) ;
@@ -85,7 +89,7 @@ export const useAnimation = (
85
89
return externalHandle ;
86
90
} ,
87
91
cancel : ( ) => {
88
- handle . _cancel ( getAnimation ( ) ) ;
92
+ cancel ( ) ;
89
93
return externalHandle ;
90
94
} ,
91
95
finish : ( ) => {
@@ -114,7 +118,7 @@ export const useAnimation = (
114
118
return [
115
119
externalHandle ,
116
120
( ) => {
117
- handle . _cancel ( getAnimation ( ) ) ;
121
+ cancel ( ) ;
118
122
} ,
119
123
] ;
120
124
} ) [ 0 ] ;
Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ export const useAnimationController = <ID extends string>(
38
38
) ;
39
39
} ;
40
40
41
+ const cancelAll = ( ) => {
42
+ forAllHandle ( ( handle ) => {
43
+ handle . cancel ( ) ;
44
+ } ) ;
45
+ } ;
46
+
41
47
const externalHandle : AnimationController < ID > = {
42
48
get : getHandle ,
43
49
playAll : ( opts ) => {
@@ -53,9 +59,7 @@ export const useAnimationController = <ID extends string>(
53
59
return externalHandle ;
54
60
} ,
55
61
cancelAll : ( ) => {
56
- forAllHandle ( ( handle ) => {
57
- handle . cancel ( ) ;
58
- } ) ;
62
+ cancelAll ( ) ;
59
63
return externalHandle ;
60
64
} ,
61
65
finishAll : ( ) => {
@@ -79,7 +83,7 @@ export const useAnimationController = <ID extends string>(
79
83
return [
80
84
externalHandle ,
81
85
( ) => {
82
- externalHandle . cancelAll ( ) ;
86
+ cancelAll ( ) ;
83
87
} ,
84
88
] ;
85
89
}
Original file line number Diff line number Diff line change @@ -79,6 +79,10 @@ export const useAnimationFunction = (
79
79
const getAnimation = ( ) => cache ?. [ 0 ] ;
80
80
const handle = createHandle ( ) ;
81
81
82
+ const cancel = ( ) => {
83
+ handle . _cancel ( getAnimation ( ) ) ;
84
+ } ;
85
+
82
86
const externalHandle : AnimationFunctionHandle = {
83
87
play : ( opts ) => {
84
88
handle . _play ( initAnimation ( getOptions ( ) ) , opts ) ;
@@ -89,7 +93,7 @@ export const useAnimationFunction = (
89
93
return externalHandle ;
90
94
} ,
91
95
cancel : ( ) => {
92
- handle . _cancel ( getAnimation ( ) ) ;
96
+ cancel ( ) ;
93
97
return externalHandle ;
94
98
} ,
95
99
finish : ( ) => {
@@ -113,7 +117,7 @@ export const useAnimationFunction = (
113
117
return [
114
118
externalHandle ,
115
119
( ) => {
116
- handle . _cancel ( getAnimation ( ) ) ;
120
+ cancel ( ) ;
117
121
} ,
118
122
] ;
119
123
}
You can’t perform that action at this time.
0 commit comments