Skip to content

Commit fc02a1b

Browse files
committed
Add support for transtion{run,start,cancel} events
1 parent 953cb02 commit fc02a1b

File tree

6 files changed

+77
-0
lines changed

6 files changed

+77
-0
lines changed

packages/react-dom-bindings/src/events/DOMEventNames.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ export type DOMEventName =
104104
| 'touchmove'
105105
| 'touchstart'
106106
// These are vendor-prefixed so you should use the exported constants instead:
107+
// 'transitionrun' |
108+
// 'transitionstart' |
109+
// 'transitioncancel' |
107110
// 'transitionend' |
108111
| 'volumechange'
109112
| 'waiting'
@@ -115,5 +118,12 @@ export const ANIMATION_ITERATION: DOMEventName =
115118
getVendorPrefixedEventName('animationiteration');
116119
export const ANIMATION_START: DOMEventName =
117120
getVendorPrefixedEventName('animationstart');
121+
122+
export const TRANSITION_RUN: DOMEventName =
123+
getVendorPrefixedEventName('transitionrun');
124+
export const TRANSITION_START: DOMEventName =
125+
getVendorPrefixedEventName('transitionstart');
126+
export const TRANSITION_CANCEL: DOMEventName =
127+
getVendorPrefixedEventName('transitioncancel');
118128
export const TRANSITION_END: DOMEventName =
119129
getVendorPrefixedEventName('transitionend');

packages/react-dom-bindings/src/events/DOMEventProperties.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import {
1414
ANIMATION_END,
1515
ANIMATION_ITERATION,
1616
ANIMATION_START,
17+
TRANSITION_RUN,
18+
TRANSITION_START,
19+
TRANSITION_CANCEL,
1720
TRANSITION_END,
1821
} from './DOMEventNames';
1922

@@ -128,5 +131,9 @@ export function registerSimpleEvents() {
128131
registerSimpleEvent('dblclick', 'onDoubleClick');
129132
registerSimpleEvent('focusin', 'onFocus');
130133
registerSimpleEvent('focusout', 'onBlur');
134+
135+
registerSimpleEvent(TRANSITION_RUN, 'onTransitionRun');
136+
registerSimpleEvent(TRANSITION_START, 'onTransitionStart');
137+
registerSimpleEvent(TRANSITION_CANCEL, 'onTransitionCancel');
131138
registerSimpleEvent(TRANSITION_END, 'onTransitionEnd');
132139
}

packages/react-dom-bindings/src/events/getVendorPrefixedEventName.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ const vendorPrefixes = {
3131
animationend: makePrefixMap('Animation', 'AnimationEnd'),
3232
animationiteration: makePrefixMap('Animation', 'AnimationIteration'),
3333
animationstart: makePrefixMap('Animation', 'AnimationStart'),
34+
transitionrun: makePrefixMap('Transition', 'TransitionRun'),
35+
transitionstart: makePrefixMap('Transition', 'TransitionStart'),
36+
transitioncancel: makePrefixMap('Transition', 'TransitionCancel'),
3437
transitionend: makePrefixMap('Transition', 'TransitionEnd'),
3538
};
3639

packages/react-dom/src/__tests__/ReactDOMEventPropagation-test.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,57 @@ describe('ReactDOMEventListener', () => {
739739
});
740740
});
741741

742+
it('onTransitionRun', () => {
743+
testNativeBubblingEvent({
744+
type: 'div',
745+
reactEvent: 'onTransitionRun',
746+
reactEventType: 'transitionrun',
747+
nativeEvent: 'transitionrun',
748+
dispatch(node) {
749+
node.dispatchEvent(
750+
new Event('transitionrun', {
751+
bubbles: true,
752+
cancelable: true,
753+
}),
754+
);
755+
},
756+
});
757+
});
758+
759+
it('onTransitionStart', () => {
760+
testNativeBubblingEvent({
761+
type: 'div',
762+
reactEvent: 'onTransitionStart',
763+
reactEventType: 'transitionstart',
764+
nativeEvent: 'transitionstart',
765+
dispatch(node) {
766+
node.dispatchEvent(
767+
new Event('transitionstart', {
768+
bubbles: true,
769+
cancelable: true,
770+
}),
771+
);
772+
},
773+
});
774+
});
775+
776+
it('onTransitionCancel', () => {
777+
testNativeBubblingEvent({
778+
type: 'div',
779+
reactEvent: 'onTransitionCancel',
780+
reactEventType: 'transitioncancel',
781+
nativeEvent: 'transitioncancel',
782+
dispatch(node) {
783+
node.dispatchEvent(
784+
new Event('transitioncancel', {
785+
bubbles: true,
786+
cancelable: true,
787+
}),
788+
);
789+
},
790+
});
791+
});
792+
742793
it('onTransitionEnd', () => {
743794
testNativeBubblingEvent({
744795
type: 'div',

packages/react-dom/src/__tests__/__snapshots__/ReactTestUtils-test.js.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ exports[`ReactTestUtils Simulate should have locally attached media events 1`] =
8383
"touchEnd",
8484
"touchMove",
8585
"touchStart",
86+
"transitionRun",
87+
"transitionStart",
88+
"transitionCancel",
8689
"transitionEnd",
8790
"volumeChange",
8891
"waiting",

packages/react-dom/src/test-utils/ReactTestUtils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,9 @@ const simulatedEventTypes = [
702702
'stalled',
703703
'suspend',
704704
'timeUpdate',
705+
'transitionRun',
706+
'transitionStart',
707+
'transitionCancel',
705708
'transitionEnd',
706709
'waiting',
707710
'mouseEnter',

0 commit comments

Comments
 (0)