1
1
import { EventHandler , TransitionEvent } from "react" ;
2
- import { combine , withHandlers , onWillReceiveProps , onDidUpdate , isolate , integrate } from "reassemble" ;
2
+ import { withHandlers , onWillReceiveProps , onDidUpdate , isolate , integrate } from "reassemble" ;
3
3
4
4
import { CSSTransitionProps } from "../csstransition" ;
5
5
@@ -11,55 +11,53 @@ type PropsOut = {
11
11
12
12
type PropsUnion = CSSTransitionProps & PropsOut ;
13
13
14
- export const preventPhantomEvents = combine (
15
- isolate (
16
- withHandlers < PropsUnion , PropsOut > (
17
- ( ) => {
18
- let lastTriggerTime : any ;
19
- let lastTriggerTimePerformance : any ;
20
- let timeUpdateRequested = false ;
21
- return {
22
- requestTimeUpdate : ( ) => ( ) => {
23
- timeUpdateRequested = true ;
24
- } ,
25
- handleTimeUpdateRequest : ( ) => ( ) => {
26
- if ( timeUpdateRequested ) {
27
- lastTriggerTime = Date . now ( ) ;
28
- if ( typeof performance !== "undefined" &&
29
- typeof performance . now !== "undefined" ) {
30
- lastTriggerTimePerformance = performance . now ( ) ;
31
- }
32
- timeUpdateRequested = false ;
14
+ export const preventPhantomEvents = isolate (
15
+ withHandlers < PropsUnion , PropsOut > (
16
+ ( ) => {
17
+ let lastTriggerTime : any ;
18
+ let lastTriggerTimePerformance : any ;
19
+ let timeUpdateRequested = false ;
20
+ return {
21
+ requestTimeUpdate : ( ) => ( ) => {
22
+ timeUpdateRequested = true ;
23
+ } ,
24
+ handleTimeUpdateRequest : ( ) => ( ) => {
25
+ if ( timeUpdateRequested ) {
26
+ lastTriggerTime = Date . now ( ) ;
27
+ if ( typeof performance !== "undefined" &&
28
+ typeof performance . now !== "undefined" ) {
29
+ lastTriggerTimePerformance = performance . now ( ) ;
33
30
}
34
- } ,
35
- onTransitionEnd : ( { onTransitionEnd} ) => ( e : TransitionEvent ) => {
36
- if ( ! onTransitionEnd ) { return ; }
31
+ timeUpdateRequested = false ;
32
+ }
33
+ } ,
34
+ onTransitionEnd : ( { onTransitionEnd} ) => ( e : TransitionEvent ) => {
35
+ if ( ! onTransitionEnd ) { return ; }
37
36
38
- // Skip transitionEnd that comes <= 10ms after (reversing) a transition.
39
- // In most cases this came from the previous transition.
40
- let compareWith = lastTriggerTime ;
41
- if ( ( e . timeStamp as any ) < 1000000000000 && lastTriggerTimePerformance ) {
42
- compareWith = lastTriggerTimePerformance ;
43
- }
44
- if ( ( e . timeStamp as any ) - compareWith <= 10 ) {
45
- return ;
46
- }
37
+ // Skip transitionEnd that comes <= 10ms after (reversing) a transition.
38
+ // In most cases this came from the previous transition.
39
+ let compareWith = lastTriggerTime ;
40
+ if ( ( e . timeStamp as any ) < 1000000000000 && lastTriggerTimePerformance ) {
41
+ compareWith = lastTriggerTimePerformance ;
42
+ }
43
+ if ( ( e . timeStamp as any ) - compareWith <= 10 ) {
44
+ return ;
45
+ }
47
46
48
- onTransitionEnd ( e ) ;
49
- } ,
50
- } ;
51
- } ) ,
52
- onWillReceiveProps < PropsUnion > (
53
- ( { active} , { active : nextActive , requestTimeUpdate} ) => {
54
- if ( active !== nextActive ) {
55
- requestTimeUpdate ( ) ;
56
- }
57
- } ) ,
58
- onDidUpdate < PropsUnion > (
59
- ( { handleTimeUpdateRequest} ) => handleTimeUpdateRequest ( ) ,
60
- ) ,
61
- integrate < keyof PropsUnion > (
62
- "onTransitionEnd" ,
63
- ) ,
47
+ onTransitionEnd ( e ) ;
48
+ } ,
49
+ } ;
50
+ } ) ,
51
+ onWillReceiveProps < PropsUnion > (
52
+ ( { active} , { active : nextActive , requestTimeUpdate} ) => {
53
+ if ( active !== nextActive ) {
54
+ requestTimeUpdate ( ) ;
55
+ }
56
+ } ) ,
57
+ onDidUpdate < PropsUnion > (
58
+ ( { handleTimeUpdateRequest} ) => handleTimeUpdateRequest ( ) ,
59
+ ) ,
60
+ integrate < keyof PropsUnion > (
61
+ "onTransitionEnd" ,
64
62
) ,
65
63
) ;
0 commit comments