* Add commercial licence and update config files
* Update license in headers
* Revert "Update license in headers"
This reverts commit 7ed7949485.
* Update only spdx id
* Remove LicenseRef- from package.json
LicenseRef- no longer allowed in npm v3 package.json
This fixes the warning in the logs and failing build check.
33 lines
936 B
TypeScript
33 lines
936 B
TypeScript
/*
|
|
Copyright 2024 New Vector Ltd.
|
|
Copyright 2021 Šimon Brandner <simon.bra.ag@gmail.com>
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
/**
|
|
* Different browsers use different deltaModes. This causes different behaviour.
|
|
* To avoid that we use this function to convert any event to pixels.
|
|
* @param {WheelEvent} event to normalize
|
|
* @returns {WheelEvent} normalized event event
|
|
*/
|
|
export function normalizeWheelEvent({ deltaMode, deltaX, deltaY, deltaZ, ...event }: WheelEvent): WheelEvent {
|
|
const LINE_HEIGHT = 18;
|
|
|
|
if (deltaMode === 1) {
|
|
// Units are lines
|
|
deltaX *= LINE_HEIGHT;
|
|
deltaY *= LINE_HEIGHT;
|
|
deltaZ *= LINE_HEIGHT;
|
|
}
|
|
|
|
return new WheelEvent("syntheticWheel", {
|
|
deltaMode: 0,
|
|
deltaY,
|
|
deltaX,
|
|
deltaZ,
|
|
...event,
|
|
});
|
|
}
|