Skip to content

Commit

Permalink
capricorn86#1092@patch: Simplifies WheelEvent.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrotoff committed Sep 24, 2023
1 parent fc25486 commit 18155b0
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions packages/happy-dom/src/event/events/WheelEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@ export default class WheelEvent extends UIEvent {
public static DOM_DELTA_PIXEL = 0;
public static DOM_DELTA_LINE = 1;
public static DOM_DELTA_PAGE = 2;
public readonly deltaX: number = 0;
public readonly deltaY: number = 0;
public readonly deltaZ: number = 0;
public readonly deltaMode: number = 0;
public readonly deltaX: number;
public readonly deltaY: number;
public readonly deltaZ: number;
public readonly deltaMode: number;

/**
* Constructor.
*
* @param type Event type.
* @param [eventInit] Event init.
*/
constructor(type: string, eventInit: IWheelEventInit = null) {
constructor(type: string, eventInit: IWheelEventInit = {}) {
super(type, eventInit);

if (eventInit) {
this.deltaX = eventInit.deltaX !== undefined ? eventInit.deltaX : 0;
this.deltaY = eventInit.deltaY !== undefined ? eventInit.deltaY : 0;
this.deltaZ = eventInit.deltaZ !== undefined ? eventInit.deltaZ : 0;
this.deltaMode = eventInit.deltaMode !== undefined ? eventInit.deltaMode : 0;
}
this.deltaX = eventInit.deltaX ?? 0;
this.deltaY = eventInit.deltaY ?? 0;
this.deltaZ = eventInit.deltaZ ?? 0;
this.deltaMode = eventInit.deltaMode ?? 0;
}
}

0 comments on commit 18155b0

Please sign in to comment.