26
loading...
This website collects cookies to deliver better user experience
function ButtonDemo(){
function showEventDifferences(e) {
console.log(e)
console.log(e.nativeEvent)
}
return (
<div>
<button
onClick={showEventDifferences}
className="lookingAtClick">
Discover Events
</button>
</div>
)
}
SyntheticBaseEvent
{_reactName: "onClick",
_targetInst: null,
type: "click",
nativeEvent: MouseEvent,
target: button.lookingAtClick, …}
altKey: false
bubbles: true
button: 0
buttons: 0
cancelable: true
clientX: 259
clientY: 618
ctrlKey: false
currentTarget: null
defaultPrevented: false
detail: 1
eventPhase: 3
getModifierState: ƒ modifierStateGetter(keyArg)
isDefaultPrevented: ƒ functionThatReturnsFalse()
isPropagationStopped: ƒ functionThatReturnsFalse()
isTrusted: true
metaKey: false
movementX: 0
movementY: 0
nativeEvent: MouseEvent {isTrusted: true,
screenX: 1723, screenY: 752,
clientX: 259, clientY: 618, …}
pageX: 259
pageY: 618
relatedTarget: null
screenX: 1723
screenY: 752
shiftKey: false
target: button.lookingAtClick
timeStamp: 734167.6999999881
type: "click"
view: Window {window: Window, self: Window,
document: document, name: "", location: Location, …}
_reactName: "onClick"
_targetInst: null
__proto__: Object
MouseEvent {isTrusted: true,
screenX: 1723, screenY: 752,
clientX: 259, clientY: 618, …}
altKey: false
bubbles: true
button: 0
buttons: 0
cancelBubble: false
cancelable: true
clientX: 259
clientY: 618
composed: true
ctrlKey: false
currentTarget: null
defaultPrevented: false
detail: 1
eventPhase: 0
fromElement: null
isTrusted: true
layerX: 259
layerY: 618
metaKey: false
movementX: 0
movementY: 0
offsetX: 90
offsetY: 13
pageX: 259
pageY: 618
path: (8) [button.lookingAtClick, div,
div, div#root, body, html, document, Window]
relatedTarget: null
returnValue: true
screenX: 1723
screenY: 752
shiftKey: false
sourceCapabilities: InputDeviceCapabilities
{firesTouchEvents: false}
srcElement: button.lookingAtClick
target: button.lookingAtClick
timeStamp: 734167.6999999881
toElement: button.lookingAtClick
type: "click"
view: Window {window: Window,
self: Window, document: document,
name: "", location: Location, …}
which: 1
x: 259
y: 618
__proto__: MouseEvent
SyntheticBaseEvent:
{_reactName: "onClick",
_targetInst: null, type: "click",
nativeEvent: MouseEvent, target: button.lookingAtClick, …}
...
eventPhase: 3
getModifierState: ƒ modifierStateGetter(keyArg)
isDefaultPrevented: ƒ functionThatReturnsFalse()
isPropagationStopped: ƒ functionThatReturnsFalse()
nativeEvent: MouseEvent {isTrusted:
true, screenX: 1723, screenY: 752,
clientX: 259, clientY: 618, …}
_reactName: "onClick"
_targetInst: null
__proto__: Object
MouseEvent {isTrusted: true,
screenX: 1723, screenY: 752,
clientX: 259, clientY: 618, …}
cancelBubble: false
composed: true
eventPhase: 0
currentTarget: null
layerX: 259
layerY: 618
offsetX: 90
offsetY: 13
returnValue: true
sourceCapabilities: InputDeviceCapabilities
{firesTouchEvents: false}
srcElement: button.lookingAtClick
which: 1
x: 259
y: 618
__proto__: MouseEvent
altKey: false
bubbles: true
button: 0
buttons: 0
cancelable: true
clientX: 259
clientY: 618
ctrlKey: false
defaultPrevented: false
isTrusted: true
metaKey: false
movementX: 0
movementY: 0
pageX: 259
pageY: 618
relatedTarget: null
screenX: 1723
screenY: 752
shiftKey: false
target: button.lookingAtClick
timeStamp: 734167.6999999881
type: "click"
view: Window {window:
Window, self: Window, document:
document, name: "", location: Location, …}
React.createEvent("OnClick", () => {
if (browser === Safari){
{return new React.SyntheticObject(Safari)
}
else if (browser === Chrome){
{return new React.SyntheticObject(Chrome)}
}
else if ...
...
__proto__: MouseEvent
(...)
get x: ƒ x()
get y: ƒ y()
__proto__: UIEvent
bubbles: (...)
cancelBubble: (...)
cancelable: (...)
composed: (...)
(...)
...
__proto__: UIEvent
(...)
get which: ƒ which()
__proto__: Event
AT_TARGET: 2
BUBBLING_PHASE: 3
CAPTURING_PHASE: 1
(...)
___proto__: Event
(...)
get timeStamp: ƒ timeStamp()
get type: ƒ type()
__proto__:
constructor: ƒ Object()
hasOwnProperty: ƒ hasOwnProperty()
isPrototypeOf: ƒ isPrototypeOf()
(...)
in index.html:
<body>
<button class="lookingAtClick">Discover Events</button>
<script src="./index.js"></script>
</body>
in index.js :
function testEventPhase(e) {
console.log(e.eventPhase)
console.log(e)
}
document.querySelector(".lookingAtClick").addEventListener("click", testEventPhase)