Skip to content

Commit 5311a43

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

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-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/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',

0 commit comments

Comments
 (0)